Jquery form Ajax Submit

Posted by user1766080 on Stack Overflow See other posts from Stack Overflow or by user1766080
Published on 2012-11-18T16:52:02Z Indexed on 2012/11/18 17:00 UTC
Read the original article Hit count: 131

Filed under:
|
|

I want to submit a form using ajax in the background. I tried:

<div class="form-horizontal" id="form">
    <label for="name" class="control-label">Username</label>
    <div class="controls">
        <span id="name_input"><input type="text" name="name" id="medium" class='input-medium input-square'></span>
        <span class="help-inline" id = "ajax_load"></span>
    </div>
    <div class="form-actions">
        <button class="btn btn-red5" onclick="resolve()">Login</button>
        <input type="reset" class='btn btn-danger' value="Reset">
    </div>                                                  
</div>

And the Javascript:

<script type="text/javascript">
    var resolve = function () {
            jAlert('test', 'test');
                $('#ajax_load').html('<a href="#" class="btn btn-mini btn-square tip" title="Reloading"><img src="templates/img/ajax-loader.gif" alt=""></a>');
                $.ajax( {
                    url : 'plugin.php?plugin=test',
                    type : 'post',          
                    data: $("#form").serialize(),
                    success : function( resp ) {
                        if(resp.ajax_success == false) {

                        } else {
                            jAlert('test', 'test');
                        }
                    }
                });     
    };
</script>

I get an alert, but there is no form submit. I checked that with Live http headers.

Why does it not submit the form?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery