$(document).ready(function() {
var options = {
target: '#output1', // target element(s) to be updated with server response
beforeSubmit: showRequest, // pre-submit callback
success: showResponse // post-submit callback
};
$('#myForm1').ajaxForm(options);
});
function showRequest(formData, jqForm, options) {
var queryString = $.param(formData);
alert('About to submit: \n\n' + queryString);
return true;
}
function showResponse(responseText, statusText) {
alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
'\n\nThe output div should have already been updated with the responseText.');
}
In the above pro开发者_StackOverflow中文版gram what is passed in the option argument?I use the http://jquery.malsup.com/
What is your question?
Please elaborate.
From the jQuery Form Plugin API Documentation:
ajaxForm
Prepares a form to be submitted via AJAX by adding all of the necessary event listeners. It does not submit the form. Use ajaxForm in your document's ready function to prepare your form(s) for AJAX submission. ajaxForm takes zero or one argument. The single argument can be either a callback function or an Options Object. Chainable: Yes.
Note: You can pass any of the standard $.ajax options to ajaxForm
target - [#outout1] is the Div which you want to reload.
beforSubmit - action you want to perform before reload
success - action you want to perform after reload
The 'beforeSubmit' callback is invoked with three arguments: the form data in array format, the jQuery object for the form, and the Options Object passed into ajaxForm/ajaxSubmit.
http://jquery.malsup.com/form/#options-object
精彩评论