$.get(url,{params}).then((data)=>{
if(data==100){
console.log(data)
}else{
console.log(data.err)
}
}).catch((err)=>{
cosole.log(err.message)
})
then里面的数据,是接口正确,接收到的结果,else里面的错误可能是参数不对,后端会返回告诉你错在哪;
catch错误,就是访问接口出现异常时执行,根本没有接收到数据。
$.get(url,{params}).then((data)=>{
if(data==100){
console.log(data)
}else{
console.log(data.err)
}
}).catch((err)=>{
cosole.log(err.message)
})
then里面的数据,是接口正确,接收到的结果,else里面的错误可能是参数不对,后端会返回告诉你错在哪;
catch错误,就是访问接口出现异常时执行,根本没有接收到数据。