您的位置:首页 > Web前端 > JavaScript

js ajax

2015-12-25 17:12 561 查看
//通用请求入口
$.extend({
ajaxReq: function(options){
var url = options.url || '';
var type = options.type|| 'get';
var data = options.data|| {};
var dataType = options.dataType || 'json';
var async = options.async || true;
var successFn = options.succuss || null;
var error = option.error || null;
var beforeFn = option.beforeSend || null;
var complete = option.complete || null;
$.ajax({
url : url,
type: type,
data: data,
dataType : dataType,
beforeSend:function(){
if(beforeFn){
beforeFn.call(null, Array.prototype.slice.call(arguments));
}
},
complete :function(){
if(complete){
complete.apply(null, Array.prototype.slice.call(arguments));
}
},
success :function(msg){
if(successFn){
successFn.call(null, msg);
}
},
error :function(){
if(error){
error.apply(null, Array.prototype.slice.call(arguments));
}
}
}
});
}
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: