关于[图片中]的这个错误,我浏览了互联网并应用了所有技术,例如Error in Chrome only: XMLHttpRequest cannot load file URL No 'Access-Control-Allow-Origin' header is present on the requested resource,但仍然无法在我的本地工作。我只是试图从系统本地[D:/ somefolder]获取JSON文件。有帮助吗?请
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="application/json; charset=UTF-8"/>
</head>
<body>
<div id="serverReply"><b><a href="#" onclick="getMessage();">Get message</a></b></div>
<script type="text/javascript">
function getMessage()
{
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("serverReply").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","carousel-data.json",true);
xmlhttp.send();
}
</script>
</body>
</html>