jquery pass form data to ajax by using (form.serialze())
jquery pass form data to ajax:
To pass the entire form data to ajax call with j query, here we have very simple code snippet
To pass the entire form data to ajax call with j query, here we have very simple code snippet
var data = $('YourFormId').serialize();
$.post('yourURL', data,function(succees){....});
or you use the bellow
var Mydata = $('YourFormId').serialize();
$.ajax({
type: "POST",
url: "yourUrl",
data: Mydata , success: function(response, textStatus, xhr) {
alert("success");
},
error: function(xhr, textStatus, errorThrown) {
alert("error");
}
});
Hope this will helps you
Labels:
Jquery