jQuery Ajax PUT with parameters

It seems that using jQuery Ajax POST will pass parameters, but PUT will not. I looked at the current jQuery code and PUT and DELETE are not there. I looked at 1.4.2 jQuery and PUT and DELETE are there.

What is the workaround for passing parameters with a PUT request using the current version of jQuery?


What's the difference between a POST and a PUT HTTP REQUEST?

PUT does not accept parameters. It is a place to "put" a resource. So I don't think you'll get parameters to work, unless it's in the URL, which probably isn't what you want to do.


Can you provide an example, because put should work fine as well?

Documentation -

The type of request to make ("POST" or "GET"); the default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.

Have the example in fiddle and the form parameters are passed fine (as it is put it will not be appended to url ) -

$.ajax({
  url: '/echo/html/',
  type: 'PUT',
  data: "name=John&location=Boston",
  success: function(data) {
    alert('Load was performed.');
  }
});

Demo tested from jQuery 1.3.2 onwards on Chrome.


对于像我这样结束的其他人,您可以使用AJAX使用参数执行PUT,但它们是作为正文发送的,而不是查询字符串。

链接地址: http://www.djcxy.com/p/7024.html

上一篇: 不应该PUT =创建和POST =更新

下一篇: 带参数的jQuery Ajax PUT