A simple jQuery plugin for changing the http method (POST/PUT/DELETE) of a simple html link or button
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENCE
README.md
bower.json
example.html
jquery.restfulizer.js

README.md

RestfulizerJs

_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.

How to use

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();

Advanced usage

You can also POST links with parameters (and also automatically setup the POST method) :

<a href="/user/create?name=John&age=18&email=test@test.com" class="rest-post">link</a>
$(".rest-post").restfulizer({
        parse: true,
        method: "POST"
});

Full options usage

$(".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)
});