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

Ajax请求跨域问题,报错XMLHttpRequest cannot load ''.

发布时间:2020-12-16 01:29:46 所属栏目:百科 来源:网络整理
导读:报错: XMLHttpRequestcannotload''.No'Access-Control-Allow-Origin'headerispresentontherequestedresource.Origin''isthereforenotallowedaccess. 原因:ajax默认不支持跨域访问,相应解决这问题很简单,加上dataType: 'JSONP'就可以完美解决 $.ajax({ ty

报错:XMLHttpRequestcannotload''.No'Access-Control-Allow-Origin'headerispresentontherequestedresource.Origin''isthereforenotallowedaccess.


原因:ajax默认不支持跨域访问,相应解决这问题很简单,加上dataType: 'JSONP'就可以完美解决


$.ajax({ type: "GET",dataType: 'JSONP',url: 'http://'+element.vm.ip+':8034/Monitor/StartMonitorMachine',data: { "configId": stdetailsvm.monitorConfigList[i].id,"itemId": itemId,"startTime": stdetailsvm.currentTime(),"ip":element.vm.ip },success: function (data) { if (data.Data == "0") { } else { alert("向服务器发送监控指令失败。"+data.Message); } },error: function (data) { alert(data.retMSG); } });

(编辑:李大同)

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

    推荐文章
      热点阅读