_Native POST support and hidden "method" input support for PUT/DELETE
A simple jQuery plugin for changing the http method (POST/PUT/DELETE) of a simple html link or button.
1: Add the jquery.restfulizer.js
file into your project including jQuery.
<script type="text/javascript" src="js/jquery.restfulizer.js"></script>
2: Use the jQuery method restfulizer()
on any link you want to customize the method :
<a href="/user/3" data-method="DELETE" class="rest">link</a>
$(".rest").restfulizer();
You can also POST links with parameters (and also automatically setup the POST method) :
<a href="/user/create?name=John&age=18&[email protected]" class="rest-post">link</a>
$(".rest-post").restfulizer({
parse: true,
method: "POST"
});
$(".rest").restfulizer({
parse: true, // Parse the URL parameters (allow to send them to POST)
method: "PUT", // The method (POST is native but PUT and DELETE will be simulated with a hidden input called "_method", this solution is handled by many PHP frameworks)
target: "example.html?specified=yes" // The target (usefull for making non link clickable)
});