Skip to main content

Bug Tracker

Side navigation

#10257 closed enhancement (plugin)

Opened September 12, 2011 05:04PM UTC

Closed September 17, 2012 01:40PM UTC

Last modified February 26, 2013 03:25PM UTC

HTTP PUT and DELETE methods shorthand functions

Reported by: alex.turpin@gmail.com Owned by:
Priority: low Milestone: None
Component: ajax Version: 1.6.3
Keywords: Cc:
Blocked by: Blocking:
Description

More and more people are using all the HTTP verbs everyday, with new server-side RESTful frameworks being released that support those. It would be nice to have some HTTP PUT and DELETE shorthand functions, a bit like jQuery.get and jQuery.post.

Attachments (0)
Change History (8)

Changed September 20, 2011 05:34PM UTC by timmywil comment:1

component: unfiledajax
priority: undecidedlow
resolution: → wontfix
status: newclosed

Unfortunately, put and delete are not supported across browsers. We could not support these consistently and it would cause confusion as many server side frameworks have their own solutions for supporting put and delete across browsers. For instance, django will always use post as the method, but add a hidden input containing the "actual" type of request. In which case, $.post is used for sending these forms with put and delete.

Changed June 17, 2012 04:42PM UTC by anonymous comment:2

"Unfortunately, put and delete are not supported across browsers."

HTML forms (up to HTML version 4 and XHTML 1) only support GET and POST as HTTP request methods. A workaround for this is to tunnel other methods through POST by using a hidden form field which is read by the server and the request dispatched accordingly.

However, for the vast majority of RESTful web services GET, POST, PUT and DELETE should be sufficient. All these methods are supported by the implementations of XMLHttpRequest in all the major web browsers (IE, Firefox, Opera).

Changed September 17, 2012 04:18AM UTC by umassthrower comment:3

Hmm, little shocked at the fact that this is not yet supported. It's unfortunate that this was brushed off 12 months ago because of misinformation.

Changed September 17, 2012 12:16PM UTC by jaubourg comment:4

Replying to [comment:3 umassthrower]:

Hmm, little shocked at the fact that this is not yet supported.

This **is** supported in ajax by setting the type option accordingly.

Changed September 17, 2012 01:39PM UTC by dmethvin comment:5

resolution: wontfix
status: closedreopened

Changed September 17, 2012 01:40PM UTC by dmethvin comment:6

resolution: → plugin
status: reopenedclosed

Anyone who wants this can easily conjure a plugin that wraps $.ajax. It doesn't belong in core.

Changed February 26, 2013 02:24PM UTC by jasonm23 comment:7

_comment0: I'm not sure where the logic of these wrappers not "belonging in the core" is coming from, by the same rationale, neither do $.get or $.post. \ \ Since they are both the same method, it's not very DRY to suggest they be shipped as a plugin, when the method is already there. \ \ $.put = $.delete = function (e,r,i,o){ \ return b.isFunction(r)&&(o=o||i,i=r,r=t), \ b.ajax({ \ url:e, \ type:n, \ dataType:o, \ data:r, \ success:i})} \ \ Is the essence of it, the type parameter is coming from the name function owner var. 1361888814565515
_comment1: I'm not sure where the logic of these wrappers not "belonging in the core" is coming from, by the same rationale, neither do $.get or $.post. \ \ Since they are both the same method, it's not very DRY to suggest they be shipped as a plugin, when the method is already there. \ \ The type parameter is coming from the name function owner var. \ \ see this JSFiddle. http://jsfiddle.net/5m4Z8/2/1361889027954847

I'm not sure where the logic of these wrappers not "belonging in the core" is coming from, by the same rationale, neither do $.get or $.post - both attach to the same method, and the object name is used as the ajax type: parameter.

Changed February 26, 2013 03:25PM UTC by alex.turpin@gmail.com comment:8

I'm not sure what's brewing up here. I was the original author of the ticket, and while I have since made it into a plugin for my own use, it should be noted that you can't use the word "delete" as a property name in JavaScript, so it would have to be called something else if ever implemented in core. I called it $.del.