Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What you are essentially asking about is called <strong>method overloading</strong> - although it's not 100% RESTful, it's an approach which you can fallback to in case that the client doesn't support PUT/DELETE methods. Richardson's/Ruby's book <a href="http://rads.stackoverflow.com/amzn/click/0596529260" rel="nofollow">RESTful Web Services</a> mentions this method as well.</p> <p>You coined the basic principle yourself in your question - the difference when compared to the fully RESTful approach is that you introduce a new parameter which is submitted as part of the request body via POST. This parameter indicates the intended method (e.g. POST/PUT/DELETE) which is being submitted via an (overloaded) POST request. This allows you to overcome the HTTP method limitation of the client while still keeping your URI design clean and RESTful (e.g. without verbs). However you should still aim to be as much RESTful as possible, i.e. keep using GET for read-only requests (thus not impacting caching, etc) and use overloaded post for any write requests. As to how to name the parameter which holds the true HTTP method - I'm not aware of any standardized naming policies myself, so going with what's used by Prototype.js (or with any name that fits well into your naming policy) should be fine.</p> <p>Regarding jQuery and <strong>XmlHttpRequest</strong> in general, these should support PUT and DELETE methods. See:</p> <ul> <li><a href="http://www.w3.org/TR/XMLHttpRequest/#the-open-method" rel="nofollow">XmlHttpRequest spec</a> (see bullet #3)</li> <li><a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">jQuery.ajax documentation</a> (see <code>type</code>)</li> </ul> <p>Note that the jQuery documentation warns about support of PUT/DELETE being browser-dependent. The way I understand it is that these methods should be supported when using XHR ... however you should rather test if all your target browsers support these methods before making a decision between POST overloading vs. the full HTTP method stack.</p> <p>jQuery by default provides access to <code>.get()</code> and <code>.post()</code> methods which are both built on top of <code>.ajax()</code>. For doing PUT/DELETE calls via jQuery you need to use <code>.ajax()</code> method directly and specify the method in <code>type</code> in settings. This however does a true PUT/DELETE request, as jQuery itself does not provide any automatic means how to handle method overloading (so you need to code it yourself so that it fits into your API design).</p> <p>If you won't be using XHR and need to rely on standard forms, then I'm afraid that you will have to use method overloading because support for PUT/DELETE methods as valid form action values has been dropped from the <a href="http://www.w3.org/TR/2010/WD-html5-diff-20101019/#changes-2010-06-24" rel="nofollow">HTML5 spec</a> (this was also noted in the SO question which you are referring to).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload