Home > Web Front-end > JS Tutorial > body text

Explanation on the use of AjaxSubmit in jQuery

巴扎黑
Release: 2017-07-03 10:48:12
Original
1410 people have browsed it

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>
Copy after login

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){
}
$(&#39;#testForm&#39;).ajaxSubmit(ajax_option);
}
</script>
//注意$("#testForm") 引号中名称必须要和form元素id值要保持一致
Copy after login

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: &#39;#output1&#39;, // 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&#39;s &#39;action&#39; attribute 
//type: type // &#39;get&#39; or &#39;post&#39;, override for form&#39;s &#39;method&#39; attribute 
//dataType: null // &#39;xml&#39;, &#39;script&#39;, or &#39;json&#39; (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 
};
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!