Reputation: 194
I am doing an Ajax call to a page, which returns HTML containing a form. I need to extract and serialize this form, to perform another Ajax call using this form data in POST. How to accomplish this with jQuery?
Here's the example code:
jQuery.ajax({
type: "POST",
url: url,
...,
success: function(data)
{
// "data" object contains HTML with a form
// extract form data from "data" object
// make another Ajax POST to another page, posting extracted form data
},
...
});
Upvotes: 1
Views: 626
Reputation: 5625
jQuery.ajax({
type: "POST",
url: url,
...,
success: function(data)
{
var formData = $(data).find("form").serialize();
$.post("/another/url", formData, callback);
},
...
});
Upvotes: 2