加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

加入跨域支持后ajax请求返回Uncaught SyntaxError: Unexpected t

发布时间:2020-12-16 01:29:42 所属栏目:百科 来源:网络整理
导读:本来正常的代码,加入跨域支持dataType: 'JSONP', $.ajax({ //contenType: "application/x-www-form-urlencoded", type: "GET", dataType: 'JSONP', url: 'http://'+element.vm.ip+':8034/Monitor/StartMonitorMachine', //url: 'http://localhost:58949/Mon

本来正常的代码,加入跨域支持dataType: 'JSONP',

$.ajax({
//contenType: "application/x-www-form-urlencoded",
type: "GET",
dataType: 'JSONP',
url: 'http://'+element.vm.ip+':8034/Monitor/StartMonitorMachine',
//url: 'http://localhost:58949/Monitor/StartMonitorMachine',

data: {
"configId": stdetailsvm.monitorConfigList[i].id,
"ReCallUrl": "http://172.16.13.10:8008",
"ip":element.vm.ip
},
success: function (data) {
if (data.Data == "0") {

} else {
alert("向服务器发送监控指令失败。"+data.Message);
}
},
error: function (data) {
alert(data.retMSG);
}
});

返回数据如下:{"Data":"0","StateCode":0,"Message":""}

但是Console里面有Uncaught SyntaxError: Unexpected token :报错


原因:Message空导致


解决方法:使Message返回数据

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读