I have an Ajax form. i am caputuring the ID of the form. and when i the ajax call is a success. i want to pass this Id form BeforeSubmit to success. so that i can append the results to a place where i want.
here is the code
function StatusComments() {
$('.status-comment').submit(function() {
$(this).ajaxSubmit(options);
return false;
});
var options = {
beforeSubmit: showRequest,
success: showResponse,
resetForm: true
};
function showRequest(formData, jqForm, options) {
var formID = $(this).attr("id");
}
function showResponse(responseText, statusText, xhr, $form) {
alert(responseText);
var formID = $(this).attr("id");
alert(formID);
}
}
The form is passed as argument to the success handler:
Also I notice that you are using the jquery form plugin and still subscribing to the
.submit
event of the form which is not necessary: