jquery pass form data to ajax by using (form.serialze())

Posted by Unknown
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



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:

Post a Comment

 
test