/* *ajax调用封装,返回json。
- handle 服务路径
- data一般为js对象
- callback 回调函数 */
function ajaxAction(url, dataType, data, callback,async) {
if(async == undefined){
async=true;
}
$.ajax({
url : url + "?r=" + (new Date().getTime()),
dataType : dataType,
data : data,
method : "post",
async:async,
success : function(ret) {
if (dataType == 'json') {
if(ret.success==false)
{ if(ret.error==undefined||ret.error ==""||ret.error ==null){
ret.error="系统运行出错,请联系系统管理员!";
}
$.messager.alert("提示信息", ret.error,"error");
callback.call(this, ret);
}else{
callback.call(this, ret);
}
} else {
ret = eval("(" + ret + ")");
if (ret.success == 'undefined'
|| ret.success == undefined) {
callback.call(this, ret);
} else {
if (ret.success == true) {
callback.call(this, ret);
} else {
$.messager.alert("提示信息", ret.error,"info");
}
}
}
},
error : function(ret, textStatus, errorThrown) {
//ret = eval("(" + ret.responseText + ")");
$.messager.alert("提示信息", ret.responseText,"error");
}
});
}