Ajax PUT请求»请求方法:选项«

时间:2013-12-26 00:00:15

标签: ajax rest put

我想向我的API发送PUT请求。当服务器和客户端在一台机器上时,一切正常。 当API在远程服务器上时,我得到404错误。 (但是URL是正确的,API也在运行;我使用PostMan(适用于Chrome的REST客户端应用程序)检查了这一点)。 请求方法在DevTools中显示为:

Request Method:OPTIONS

在搜索网页后,我发现它与

有关
Access-Control-Allow-Methods:GET, POST, PUT, DELETE
Access-Control-Allow-Origin:*

所以我将API响应更改为上面的示例。

以下是标题的完整输出:

Request URL:http://example.org/api
Request Method:OPTIONS
Status Code:404 Not Found
**Request Headers**
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,de;q=0.6
Access-Control-Request-Headers:accept, content-type
Access-Control-Request-Method:PUT
Cache-Control:no-cache
Connection:keep-alive
Host:example.org
Origin:http://localhost
Pragma:no-cache
Referer:http://localhost/svpoffline/index.html
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu         Chromium/31.0.1650.63 Chrome/31.0.1650.63 Safari/537.36
**Response Headers**
Access-Control-Allow-Headers:X-Custom-Header
Access-Control-Allow-Methods:GET, POST, PUT, DELETE
Access-Control-Allow-Origin:*
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:368
Content-Type:text/html
Date:Wed, 25 Dec 2013 23:47:35 GMT
Keep-Alive:timeout=1, max=100
Server:Apache
Vary:Accept-Encoding
X-Powered-By:PHP/5.4.21-nmm1

0 个答案:

没有答案