ajaxForm组件
Intro
一款简单实用且支持XMLHttpRequest 2
的表单 ajax 提交组件,
Author
name:janking
concat:[email protected]
Options
@param {String} url ajax url
@param {String} method [default:post],get,post...
@param {String} type [default:json],html,json,xml ...
@param {Boolean} ajax2 [default:false]
@param {Function} before ajax before callback
@param {Function} success ajax success callback
@param {Function} error ajax error callback
@param {Function} pending ajax pedding callback
@param {Function} always ajax always callback
Usage
$('form').IUI('ajaxForm',{
url:'/xxxxx/xxxx/xxx',
type:'json',
ajax2:false,
method:'post',
pedding:function(config){
// this --> form
// config --> ajaxForm config
},
before:function(event,config){
// this --> form
// event --> submit event
// config --> ajaxForm config
},
success:function(res,config){
// this --> form
// res --> ajax response
// config --> ajaxForm config
},
error:function(err,config){
// this --> form
// err --> ajax error
// config --> ajaxForm config
},
always:function(res,config){
// this --> form
// res --> ajax response
// config --> ajaxForm config
}
})
Attention
- 当调用
ajaxForm
后,$('form').data('deferred')
可读写到config
对象