首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >jQuery ajax调用支持补丁吗?

jQuery ajax调用支持补丁吗?
EN

Stack Overflow用户
提问于 2012-11-30 17:11:20
回答 1查看 57.7K关注 0票数 35

当我发送此ajax请求时:

代码语言:javascript
复制
$.ajax({
            headers : {
                'Accept' : 'application/json',
                'Content-Type' : 'application/json'
            },
            url : 'http://localhost:8080/wutup/venues/12',
            type : 'PATCH',
            data : JSON.stringify({description: "842490812321309213801923 gonzagazors"}),
            success : function(response, textStatus, jqXhr) {
                console.log("Venue Successfully Patched!");
            },
            error : function(jqXHR, textStatus, errorThrown) {
                // log the error to the console
                console.log("The following error occured: " + textStatus, errorThrown);
            },
            complete : function() {
                console.log("Venue Patch Ran");
            }
        });

我收到这个错误:

XMLHttpRequest无法加载。Access-Control-Allow-Methods不允许方法修补。

但是,使用curl:

代码语言:javascript
复制
 $ curl -v -H "Accept: application/json" -H "Content-type: application/json" -X PATCH -    d' {"address": "8421 Gonzaga Ave"}'  http://localhost:8080/wutup/venues/12 

About to connect() to localhost port 8080 (#0)
Trying 127.0.0.1... connected
Connected to localhost (127.0.0.1) port 8080 (#0)
PATCH /wutup/venues/12 HTTP/1.1
User-Agent: curl/7.21.1 (i686-pc-mingw32) libcurl/7.21.1 OpenSSL/0.9.8r zlib/1.2.3
Host: localhost:8080
Accept: application/json
Content-type: application/json
Content-Length: 57

HTTP/1.1 204 No Content
Server: Apache-Coyote/1.1
Access-Control-Allow-Origin: *
Date: Fri, 30 Nov 2012 08:14:35 GMT

Connection #0 to host localhost left intact
Closing connection #0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13642044

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档