Skip to content Skip to sidebar Skip to footer

Jquery .post And Form Data

I am using .post to post my data to my controller. I would like to pass all the data that I have in a form. Is there an easy way to take all the form data and add it to the .post c

Solution 1:

use the .serialize method.

var postData = $('#formId').serialize();
$.post(url,  postData);

Solution 2:

$("form").submit(function(e) {
    e.preventDefault();
    $.post("/url", $(this).serialize(), callbackFunction);
});

Solution 3:

jquery form plugin is what you need.

Post a Comment for "Jquery .post And Form Data"