我用下面的脚本 -访问控制允许来源错误
<!DOCTYPE html>
<html>
<head>
<script src="jquery-1.9.1.min.js"></script>
<script>
function postForm() {
$.ajax({
type: 'POST',
url: 'http://10.0.0.8:9000/demo',
data: {"name" : "test"},
contentType: "application/json; charset=utf-8",
dataType: 'json',
})
}
</script>
</head>
<body>
<form id="ajaxForm" onsubmit="postForm(); return false; " method="post">
<input id="test" type="text" name="name" value="Hello JSON" />
<input type="submit" value="Submit JSON" />
</form>
</body>
</html>
我试图访问该计算机正在运行的游戏框架。我收到以下错误:
OPTIONS http://10.0.0.8:9000/demo
404(未找到)的jquery-1.9.1.min.js:5 的XMLHttpRequest不能加载http://10.0.0.8:9000/demo
。 Access-Control-Allow-Origin不允许产生http://localhost:8080
。
我已经被困了两天,任何人都可以帮我吗?
感谢提前
注意:'contentType'是'**内容类型'标头***发送给**请求**中的服务器!这不是***回应的“内容类型”。这里不正确。 – 2013-03-14 14:50:14
这是另一种解决方案; http://stackoverflow.com/questions/7564832/how-to-bypass-access-control-allow-origin/17098221#17098221 – 2014-02-26 21:07:58