/**
* {tokenType}: 0 不许要验证登录借口 1.需要登录取值的借口
* {type}:post ||get
* {dataApi}:接口地址
* {params}:参数JSON.stringify()
* {callBack}:回调
*
* **/
varhttpRequest=function(type,dataApi,params,callBack)
{
varSid=localStorage.getItem(strKey.KSESSIONID);
if(Sid==undefined)
{
Sid="";
}
varsendParams={};
sendParams.Data=JSON.stringify(params);
sendParams.Sid=Sid;
$.ajax({
url:dataApi,
async:true,
type:type,
data:sendParams,
dataType:"json",
xhrFields:{
withCredentials:true
},
success:function(data){
varerr=data["code"];
varerrMsg=data["message"];
if(err!=0)
{
if(errMsg!="")
{
common.toast(0,errMsg);
}
if(err==101)
{
location.href="login.html";
common.toast(0,errMsg);
}
}
else
{
callback(data["data"]);
}
},
error:function(XMLHttpRequest,textStatus,errorrThrown){
alert("网络出错!");
}
});
};
varhttpRequestDefault=function(type,dataApi,params,callBack)
{
varsendParams={};
sendParams.Data=JSON.stringify(params);
$.ajax({
url:dataApi,
async:true,
type:type,
data:sendParams,
dataType:"Json",
xhrFields:{
withCredentials:true
},
success:function(data){
callBack(data)
},
error:function(XMLHttpRequest,textStatus,errorrThrown){
alert("网络出错!");
}
})
}
网友评论