Unable to make PUT/POST/DELETE HTTP Call using CORS in JQuery 1.6.4

谁说我不能喝 提交于 2019-12-02 18:23:22

You need to include CORS headers in both the preflight and the actual response. So try including the following headers in the PUT response from your server:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE
Access-Control-Allow-Headers: Content-Type

One other thing to note is that the CORS spec does not list '*' as a valid value for Access-Control-Allow-Headers:

http://www.w3.org/TR/cors/#access-control-allow-headers-response-he

Instead, you should try explicitly listing all the request headers like so:

Access-Control-Allow-Headers: Content-Type

You must include Content-Type because the Content-Type is not considered a simple header when its value is not application/x-www-form-urlencoded, multipart/form-data, or text/plain (See the CORS spec for more details on simple headers).

user200068

Don't forget to make sure your prefight Options request also responded with:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE
Access-Control-Allow-Headers: Content-Type
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!