Ajaxsubmit use in Jquery

Source: Internet
Author: User

Recently, using Ajaxform, jot down the use of the method, in order to review later.

1, introducing a dependent script

<script type= "Text/javascript" src= "/js/jquery/jquery.form.js" ></script>//ajaxform dependent scripts

<script type= "Text/javascript" src= "/js/jquery/jquery-1.8.0.min.js" ></script>
<script type= "Text/javascript" src= "/js/jquery/jquery.easyui.min.js" ></script>

2 How to use

<form name= "Testform" id= "Testform" >

<input type= "button" value= "Submit"/>

</form>

<script type= "Text/javascript" >

var ajax_option={

URL: "Login",//default is form action

Success:function (data) {

}

$ (' #testForm '). Ajaxsubmit (ajax_option);

}

</script>

Note the name in the $ ("#testForm") quotation mark must be consistent with the form element ID value

3 Ajaxsubmit and Ajaxform differences

Ajaxform cannot submit the form. In the ready function of document, use Ajaxform to prepare the form for the AJAX submission. Submit action must be started by submit

Ajaxsubmit immediately submits the form by Ajax. You can make the submission under any circumstances.

4

Option's Parameters
var options = {
Target: ' #output1 ',//target element (s) to being updated with server response
Beforesubmit:showrequest,//Pre-submit callback
Success:showresponse//Post-submit callback

Other available options:
Url:url//Override for form ' s ' action ' attribute
Type:type//' get ' or ' post ', override for form ' s ' method ' attribute
Datatype:null//' xml ', ' script ', or ' JSON ' (expected server response type)
Clearform:true//Clear all form fields after successful submit
Resetform:true//Reset the form after successful submit

$.ajax options can used here too, for example:
timeout:3000
};

Ajaxsubmit use in Jquery

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.