报错: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); } });