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