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));
}
}
}
});
}
});
$.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));
}
}
}
});
}
});
相关文章推荐
- JSON-lib框架,转换JSON、XML不再困难
- javascript之DOM操作
- 在javascript中关于submit和button提交表单区别
- extjs 按条件查询出的数据在grid上不显示
- javascript图片预加载实例分析
- js数据过滤
- javascript中的super
- 【JAVASCRIPT】JS实现淘宝,百度评分功能
- js方法数据验证
- 不得不分享的JavaScript常用方法函数集(下)
- 常用jstl标签小结
- JS正则中的RegExp对象对象
- ArcGIS API for JavaScript 学习之 identifyTask
- javaWeb学习笔记-----3 javascript
- JavaScript的Cookie操作
- maven依赖servlet-api和jsp-api的问题
- js学习笔记之基础知识
- js中 push pop shift unshift方法
- javascript 前端 基于 npm、bower、grunt的标准项目构建
- JS控制按钮10秒钟后可用的方法