Detailed explanation of ajaxSubmit in jQuery

小云云
Release: 2019-11-26 09:29:08
Original
16523 people have browsed it

I was just learning and used ajaxSubmit. I hesitated because I had never been exposed to this before, so I was confused at first. Finally, I solved this problem by searching for information. I was very excited and uploaded the page without refreshing. Picture, I would like to give a sentence to friends who read my blog: "The mountain is high, and hard work will determine success!"

Let me summarize ajaxSubmit below:

1.Introduce jQuery;

2.Download the jQuery Form plug-in online;

Here is an introduction to the form plug-in, because people who are just starting to do front-end work may not understand it. , jQuery Form plug-in is an excellent Ajax form plug-in, which can easily and non-invasively upgrade HTML forms to support Ajax.

jQuery Form has two core methods - ajaxForm() and ajaxSubmit(), which combine functions from controlling form elements to deciding how to manage the submission process.

In addition, the plug-in also includes other methods:

formToArray(), formSerialize(), fieldSerialize(), fieldValue(), clearForm(), clearFields() and resetForm ()wait.

Core methods: ajaxForm() and ajaxSubmit()

3. Let’s talk about usage first. Both ajaxForm and ajaxSubmit can receive 0 or 1 parameter, which can be a variable, An object or callback function. This object mainly has the following parameters:

var object= { url:url,      //form提交数据的地址        type:type,    //form提交的方式(method:post/get)        target:target,  //服务器返回的响应数据显示的元素(Id)号 beforeSerialize:function(){} //序列化提交数据之前的回调函数        beforeSubmit:function(){},  //提交前执行的回调函数        success:function(){},     //提交成功后执行的回调函数 error:function(){}, //提交失败执行的函数        dataType:null,       //服务器返回数据类型        clearForm:true,       //提交成功后是否清空表单中的字段值        restForm:true,       //提交成功后是否重置表单中的字段值,即恢复到页面加载时的状态        timeout:6000         //设置请求时间,超过该时间后,自动退出请求,单位(毫秒)。   }
Copy after login
Recommended Manual:
1. AJAX Chinese Reference Manual
2. jQuery Chinese Reference Manual
   权限信息展示     //这里引入