跨源资源共享

你好,我一直在读“CORS”。

我想我理解这个概念。 但是我在执行跨域POST请求时遇到了一些困难。

我在我的本地IIS上设置了两个测试站点。

http://localhost/CORSService/hello.html http://localhost:8000/CORSClient/index.html 

目前,以下代码有效:

       This is my Hello World: ""  $.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); } });    

但是,只要我将类型“GET”更改为“POST” ,我就会收到405 Method Not Allowed,错误。

我在IIS7.5中托管测试站点。 我已将以下HTTP响应标头添加到http://localhost/CORSServer上托管的站点

 Access-Control-Allow-Origin: http://localhost:8000 Access-Control-Allow-Methods: POST Access-Control-Allow-Credentials: true 

我可能误解了我读过的消息来源,我假设Cross Domain POSTing可用于CORS?

任何人都可以看到我做错了什么,或者我误解了什么?

干杯,

詹姆士

它可能是这样的: http : //support.microsoft.com/kb/942051/en-us

决议2

不是将HTTP请求发送到静态HTML页面,而是通过将POST方法发送到Active Server Pages(ASP)页面来发出HTTP请求。