我试图在顶点之外调用一个页面,但它不起作用。当我单击顶点中的按钮时,会触发动态操作。这是一个javascript块,其代码如下:
var xmlhttp;
var name = document.getElementById('P1_X').value;
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){
alert(xmlhttp.responseText);
}
}
xmlhttp.setRequestHeader("Access-Control-Allow-Origin", "*");
xmlhttp.setRequestHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
xmlhttp.setRequestHeader("Access-Control-Max-Age", "3600");
xmlhttp.setRequestHeader("Access-Control-Allow-Headers", "x-requested-with");
xmlhttp.open("GET","http://92.109.55.51:7070/xander/rest/templates/" + name,true);
xmlhttp.send();
我收到以下错误没有 setRequestHeader
行:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://92.109.55.51:7070/xander/rest/templates/Test1. This can be fixed by moving the resource to the same domain or enabling CORS.
我已经浏览了互联网并尝试了我的标题(Source),如代码中所示,但我不知道在哪里放置标题部分。目前我得到了:
InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable
如何通过动态操作从顶层获取信息?