I have been using ajaxform quite frequently recently. Today I took the time to record the knowledge about the use of ajax in jquerySubmit. It is very good. Friends who are interested can refer to it
I've been using ajaxForm recently, so I just jot down how to use it so that I can review it later.
1, introduce dependency script
<script type="text/javascript" src="/js/jquery/jquery.form.js"></script> //ajaxForm 依赖脚本 <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 Usage method
<form name="testForm" id="testForm" > <input type="button" value="submit"/> </form> <script type="text/javascript"> var ajax_option={ url:"login",//默认是form action success:function(data){ } $('#testForm').ajaxSubmit(ajax_option); } </script> //注意$("#testForm") 引号中名称必须要和form元素id值要保持一致
3 The difference between ajaxSubmit and ajaxForm
ajaxForm cannot submit the form. In the ready function of document, use ajaxForm to prepare for AJAX submission of the form. The submission action must start with submit
ajaxSubmit The form will be submitted immediately by AJAX. You can make this submission under any circumstances.
4 option parameters
var options = { target: '#output1', // target element(s) to be 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 be used here too, for example: //timeout: 3000 };
The above is the editor’s introduction to the use of AjaxSubmit in jQuery. I hope It will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for your support of the Script House website!
The above is the detailed content of Explanation on the use of AjaxSubmit in jQuery. For more information, please follow other related articles on the PHP Chinese website!