$.ajax.submit,jQuery中的AjaxSubmit使用讲解
最近在使用ajaxForm,隨便把使用方法記下下來,以便以后回顧。
1 ,引入依賴腳本
//ajaxForm 依賴腳本
2 使用方法
var ajax_option={
url:"login",//默認(rèn)是form action
success:function(data){
}
$('#testForm').ajaxSubmit(ajax_option);
}
//注意$("#testForm") 引號中名稱必須要和form元素id值要保持一致
3 ajaxSubmit 和ajaxForm區(qū)別
ajaxForm不能提交表單。在document的ready函數(shù)中,使用ajaxForm來為AJAX提交表單進(jìn)行準(zhǔn)備。提交動作必須由submit開始
ajaxSubmit 馬上由AJAX來提交表單。你可以在任何情況下進(jìn)行該項提交。
4 option的參數(shù)
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
};
以上所述是小編給大家介紹的jQuery中的AjaxSubmit使用講解,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
總結(jié)
以上是生活随笔為你收集整理的$.ajax.submit,jQuery中的AjaxSubmit使用讲解的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用邮箱注册帐户以及激活
- 下一篇: powershell新建python文件