Skip to content

Instantly share code, notes, and snippets.

@fragoulis
Created June 13, 2014 11:45
Show Gist options
  • Save fragoulis/0ff3bdfd57eb0ce1074f to your computer and use it in GitHub Desktop.
Save fragoulis/0ff3bdfd57eb0ce1074f to your computer and use it in GitHub Desktop.
Enables clients to submit empty POST, PUT and DELETE requests using simple links.
@fragoulis
Copy link
Author

Say you want to delete an object with ID equal to 1 (not with ajax) using something as simple as a link but also conform with the REST principle, which means that the request method should be DELETE and the object url should be something like http://www.venture.com/api/v1/object/1

Simple usage:

<a href="http://www.venture.com/api/v1/object/1" data-method="delete">Delete Object</a>

This way you can keep your server side code clean (delete objects only on DELETE requests) and also use simple form submission.

Also, in case it is not obvious, HTML5 form does not support PUT and DELETE methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment