1
你好我一直在读“CORS”。跨源起源资源共享
我想我理解这个概念。不过,我在执行跨域POST请求时遇到了一些困难。
我在本地IIS上设置了两个测试网站。
http://localhost/CORSService/hello.html
http://localhost:8000/CORSClient/index.html
目前,下面的代码工作:
<html>
<head>
<title></title>
<script src="jquery-1.4.3.js" type="text/javascript" language="javascript"></script>
</head>
<body>
This is my Hello World: "<span id="helloSpan" style="color: red"></span>"
<script>
$.ajax({
url: "http://localhost/CORSServer/hello.html",
type: "GET",
data: {words: ["tes"]},
dataType: "json",
cache: false,
contentType: "application/json",
success: function(result)
{
$("#helloSpan").html(result.words[0]);
},
error: function(a, b, c)
{
$("#helloSpan").html(a + ' ------- ' + b + ' ------- ' + c);
}
});
</script>
</body>
</html>
然而,当我从改变型 “GET”到“POST”,我收到405方法不允许,错误。
我在IIS7.5中托管测试网站。我已经添加在http://localhost/CORSServer
Access-Control-Allow-Origin: http://localhost:8000
Access-Control-Allow-Methods: POST
Access-Control-Allow-Credentials: true
举办了以下HTTP响应头到现场我可能误解我读到的资料,我假设跨域发布可与CORS?
任何人都可以看到我做错了什么,或者我误解了一些东西吗?
干杯,
詹姆斯
干杯队友,这并没有发生在我身上,非常感谢! – Zack 2010-11-11 10:58:55