开发者

How to do REST with PUT and DELETE

开发者 https://www.devze.com 2023-01-03 15:35 出处:网络
It says about the type option of the jQuery.ajax() method that The type of request to make (\"POST\" or \"GET\"), default is \"开发者_运维百科GET\". Note: Other HTTP request methods, such as PUT and

It says about the type option of the jQuery.ajax() method that

The type of request to make ("POST" or "GET"), 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.

So...

  1. Does that mean that PUT and DELETE won't work if the browser does not support it, or just that PUT and DELETE can not be done natively by the user in the browser?

  2. If I can't or shouldn't use those, what do people usually do instead? Send the method as a a GET or POST parameter instead? Or?


PUT and DELETE won't work if the browser doesn't support it. The usual workaround is to do a POST request with an extra field that holds the method (e.g. _method="PUT" in the POST values). Some web frameworks (Spring MVC, Ruby on Rails) will do this kind of thing for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消