小编Chr*_*ean的帖子

无法在JQuery 1.6.4中使用CORS进行PUT/POST/DELETE HTTP调用

所以,我可以使用CORS成功地对我的服务进行GET调用.但是,在POST,PUT和DELETE操作的预检级别上必须出错.但是,根据我的判断,我的服务器响应OPTIONS查询返回的标头响应是正确的,并与之中描述的匹配

这是我的javascript代码,在JQuery 1.6.4中使用$ .ajax.

$.ajax({
  url: 'http://myhome:8080/TaskApproval/resources/tasks/2',
  context: this,
  data: '<?xml version="1.0" encoding="UTF-8"?> <task> <description>Get carrots from the grocery store</description><originator>Chris</originator><subject>Get Carrots !!</subject><taskId>2</taskId> </task> ',
  timeout: 30000,
  type: 'PUT',
  contentType: 'application/xml',
  success: function(response) {
    alert(response);
    result = response;
  },
  error: function(xhr) {
    alert('Error!  Status = ' + xhr.status + " Message = " + xhr.statusText);
  }
});
Run Code Online (Sandbox Code Playgroud)

现在,这就是我的HTTP Trail看起来像Firebug的礼貌.

请求:

OPTIONS /TaskApproval/resources/tasks/2 HTTP/1.1
Host: widgethome:8080
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: …
Run Code Online (Sandbox Code Playgroud)

jquery http put cors

14
推荐指数
1
解决办法
3万
查看次数

标签 统计

cors ×1

http ×1

jquery ×1

put ×1