P. 1
jquery-docs-with-plugins

jquery-docs-with-plugins

|Views: 267|Likes:
Published by api-3854120

More info:

Published by: api-3854120 on Dec 04, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

ajaxSubmit(options object) returns jQuery

ajaxSubmit() provides a mechanism for submitting an HTML form using AJAX.

ajaxSubmit accepts a single argument which can be either a success callback function or an

options Object. If a function is provided it will be invoked upon successful completion of the

submit and will be passed the response from the server. If an options Object is provided, the

following attributes are supported:

target: Identifies the element(s) in the page to be updated with the server response.

This value may be specified as a jQuery selection string, a jQuery object,

or a DOM element.

default value: null

url: URL to which the form data will be submitted.

default value: value of form's 'action' attribute

method:

Example:

Submit form and alert server response

$('#myForm').ajaxSubmit(function(data) {

alert('Form submit succeeded! Server returned: ' + data);

});

Example:

Submit form and update page element with server response

var options = {

target: '#myTargetDiv'

};

$('#myForm').ajaxSubmit(options);

Example:

Submit form and alert the server response

var options = {

success: function(responseText) {

alert(responseText);

}

};

$('#myForm').ajaxSubmit(options);

Example:

Pre-submit validation which aborts the submit operation if form data is empty

var options = {

beforeSubmit: function(formArray, jqForm) {

if (formArray.length == 0) {

alert('Please enter data.');

return false;

}

}

};

$('#myForm').ajaxSubmit(options);

Example:

json data returned and evaluated

var options = {

url: myJsonUrl.php,

dataType: 'json',

success: function(data) {

// 'data' is an object representing the the evaluated json data

}

};

$('#myForm').ajaxSubmit(options);

Example:

XML data returned from server

var options = {

url: myXmlUrl.php,

dataType: 'xml',

success: function(responseXML) {

// responseXML is XML document object

var data = $('myElement', responseXML).text();

}

};

$('#myForm').ajaxSubmit(options);

Example:

submit form and reset it if successful

var options = {

resetForm: true

};

$('#myForm').ajaxSubmit(options);

Example:

Bind form's submit event to use ajaxSubmit

$('#myForm).submit(function() {

$(this).ajaxSubmit();

return false;

});

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->