I have the following jQuery code:
$(".save_button").click(function() {
var $form = $(this).closest("div.info_section").find("form");
url = $form.attr("action");
$.post(url, $form.serialize(),
function() {
// need to figure out a way to distinguish the form being saved
}
);
});
I have three forms (on the same page) that are tied to this function. The success callback function of $.post requires a way to distinguish which form is being submitted. Please advise 开发者_如何转开发how I would do so. Thanks.
You could use the $form
variable inside the success
callback:
$.post(url, $form.serialize(), function() {
// $form could be used here to access the form element
// whose contents was serialized and sent in the AJAX request
});
精彩评论