ajax type patch,javascript - Does the jQuery ajax call support PATCH? - Stack Overflow

When I send this ajax rquest:

$.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");

}

});

I receive this error:

XMLHttpRequest cannot load http ://localhost:8080/wutup/venues/12. Method PATCH is not allowed by Access-Control-Allow-Methods.

However, using curl:

$ 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值