使用$.ajax 来调取后台接口,一定要用try/catch包起来
1、因为如果不用try/catch 包起来,如果遇到连不上接口的情况,就会只在控制台输出信息,前台收不到报错信息
try{
var response = await $.ajax({type: 'POST',url: url,data: null,contentType: "application/json;charset=UTF-8",dataType: "json"})
if (response.code == 200) {
const itemId = response.data.problemCode
createIssue(data,itemId,ctx)
} else {
msg.showError("获取项目流水码失败,失败原因:"+response.message)
return false
}
}catch(errorMsg){
msg.showError("获取项目流水码失败,请联系管理员!")
condition.is_sumbit=true
}

浙公网安备 33010602011771号