JQuery.form.js is a form plugin that supports AJAX form submissions and Ajax file uploads.
Baidu Cloud: http://pan.baidu.com/s/1eQoYE46
360 Cloud: Http://yunpan.cn/Qi7B5wdiewUMP access password 06b6
Micro Cloud: http://url.cn/QMQ79w
View Code
Api
Ajaxform |
Add all the required event listeners to prepare for the AJAX submission form. Ajaxform cannot submit the form. In the ready function of document, use Ajaxform to prepare the form for the AJAX submission. |
accepts 0 or 1 parameters. A parameter can be a callback function, or it can be an options object. |
$ ("#formid"). Ajaxform (); |
Ajaxsubmit |
Submit a form using AJAX. |
accepts 0 or 1 parameters. A parameter can be a callback function, or it can be an options object. |
$ ("#formid"). Ajaxsubmit (); Or $ ("#formid"). Submit (function () { $ (this). Ajaxsubmit (); return false; }); |
Formserialize |
Serializes (or serialize) a form into a query string. This method returns a string in the following format: Name1=value1&name2=value2. |
No |
$ ("#formid"). Formserialize (); |
Fieldserialize |
Serializes (or serialize) the field elements of a form into a single query string. This is handy when only a subset of the form fields need to be serialized (or serializable). Returns a string in the following format: Name=value1&name2=value2. |
No |
$ ("#formid. Specialfields"). Fieldserialize (); |
Fieldvalue |
Returns the value of the form element that matches the inserted array. The method returns data in the form of an array. If the element value is determined to be invalid, the array is empty. |
No |
$ ("#formid:p assword"). Fieldvalue (); |
Resetform |
Restores the form to its original state. |
No |
$ ("#formid"). Resetform (); |
ClearForm |
Clears the form element. This method resets all text, password, textarea, clears the selection in the Select element, and resets all radio and CheckBox buttons to the unselected state. |
No |
$ ("#formid"). ClearForm (); |
Clearfields |
Clears the field element. Only some form elements are easy to use when they need to be cleared. |
No |
$ ("#formid. Specialfields"). Clearfields (); |
Options Object
Both Ajaxform and Ajaxsubmit support a wide range of option parameters, which can be provided using an options object.
target |
indicates the element in the page that is updated by the server response. The value of the element may be specified as a jquery selector string, a jquery object, and a DOM element. |
default value: null |
URL |
Specifies the URL to submit the form data. |
Default: The Action property value of the form |
type |
Specifies the method by which the form data is submitted: "GET" or "POST". |
default: Get |
beforesubmit |
The callback function that was called before the form was submitted. If the callback function returns false, the form will not be committed. The callback function takes three invocation parameters: the form data as an array, the JQuery form object, and the options object in the incoming ajaxform/ajaxsubmit. |
default: null |
Success |
The callback function that was called after the form was successfully committed. The datatype option value then determines whether to return ResponseText or responsexml values. |
default: null |
dataType |
One of the data types returned: null, XML, script, JSON. |
default value: null |
resetform |
Indicates whether the form submission succeeds if it is reset. |
default: null |
clearform |
Indicates whether form data is purged if the form is submitted successfully. |
default value: null |
varoptions={target:' #output ',//put the contents returned by the server into an element with ID outputBeforesubmit:showrequest,//Pre-commit callback functionSuccess:showresponse,//Post-Commit callback function //Url:url,//default is the action of form, if stated, Overrides //Type:type,//The default value is the method of form ("GET" or "POST"), and if declared, overrides //datatype:null,//html (default), XML, script, JSON accept server-side returned types //Clearform:true,//After successful commit, clears the values of all form elements //Resetform:true,//After successful commit, resets the values of all form elementstimeout:3000//limit the time of the request, when the request is greater than 3 seconds, jump out of the request } functionshowrequest (FormData, Jqform, options) {//formData: An Array object, when the form is submitted, the form plug-in automatically submits the data in an AJAX format such as [{name:user,value:val},{name:pwd,value:pwd}] //Jqform:jquery object that encapsulates the elements of the form //Options:options Object varQuerystring=$.param (FormData);//name=1&address=2 varFORMELEMENT=JQFORM[0];//convert Jqform to DOM object varAddress=formelement.address.value;//accessing the DOM elements of Jqform return true;//The form will be submitted as long as it does not return false, where the form elements can be validated } functionShowresponse (responsetext,statustext) {//Datatype=xml varname=$ ("name", Responsexml). text (); varaddress=$ ("Address", Responsexml). text (); $("#xmlout"). HTML (name+ "" +address); //Datatype=json$ ("#jsonout"). HTML (data.name+ "" +data.address); }
JQuery.form.js use