【发布时间】:2013-03-02 23:26:00
【问题描述】:
我正在使用以下脚本 -
<!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>
我尝试访问的计算机正在运行播放框架。我收到以下错误:
选项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是 sent 到 request 中的服务器的Content-type标头!它不是响应的Content-type。这里不正确。 -
这是另一个解决方案; stackoverflow.com/questions/7564832/…
标签: jquery ajax json playframework