t9lr2a
Last Updated: February 25, 2016
·
1.363K
· dizpers
3845a56

AJAX form submit with jQuery

Method 1

$.get('server.php?' + $('#theForm').serialize())

$.post('server.php', $('#theForm').serialize())

Method 2

With use of jQuery form plugin.

Send when the "Submit" button is pressed:

$("#theForm").ajaxForm({url: 'server.php', type: 'post'})

Send immediately:

$("#theForm").ajaxSubmit({url: 'server.php', type: 'post'})

Based on this SO answer.

Say Thanks
Respond

1 Response
Add your response

4744
190043 533696520020804 1840519452 n

Method 3

$('form').on('submit', function() {

    var $form = $(this);

    $.post( $form.attr('action'), $form.serialize(), function(response) {

        var response = $.parseJSON(response);

        console.log("Response: ", response);

    });

    return false;

});
over 1 year ago ·