【发布时间】:2015-07-19 02:59:31
【问题描述】:
我想使用 xmlhttprequest 和 javascript 调用 html 在线链接,这是我的代码 但是当代码到达 xmlhttp.open 时它停止并且不会继续执行
function loadXMLDoc(size,downloadfromurl) {
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var temp = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "http://app.arsel.qa/mobileappspeedtest/samples/256.htm?n=" + Math.random(), false);
xmlhttp.send(null);
}
【问题讨论】:
-
上述目标不支持 CORS,因此由于同源策略限制,您无法向资源发出跨域 ajax 请求
-
是的,我认为我必须通过此链接在 Web 服务中启用 CORS asp.net/web-api/overview/security/…
标签: javascript jquery html xmlhttprequest