More HTTP methods for jQuery.ajax
, emulated for cross-browser support.
Enhance forms with method overrides.
Great for integrating with a RESTful API (see Framework support).
Uses conventions like the X-HTTP-Method-Override
header and the hidden _method
parameter to proxy the lesser-used methods through the fully-supported GET
and POST
.
The "useful" methods from RFC 2616 are supported, proxied as follows:
PUT
:POST
PATCH
:POST
DELETE
:POST
HEAD
:GET
OPTIONS
:GET
Via bower as jquery-methodOverride
.
bower install --save jquery-methodOverride
Include on your page, after jQuery. Supports AMD.
The following methods will become available, which simultaneously support both $.ajax
and $.get
/$.post
APIs.
$.put(/* ... */);
$.patch(/* ... */);
$.delete(/* ... */);
$.head(/* ... */);
$.options(/* ... */);
For API details, refer to:
To enhance a form with method override, use $.fn.methodOverride
.
Given the following form:
<form method="put">
<!-- ... -->
</form>
And adding the following script:
$('form').methodOverride();
Will result in the following enhanced form:
<form method="POST" data-method-override="put">
<!-- ... -->
<input type="hidden" name="_method" value="put">
</form>
-
$.fn.methodOverride.map
:function (method:String) : String
Maps a method to its override method, if any.
-
$.fn.methodOverride.methods
:Object.<String>
The raw object mapping methods to their override methods.