Skip to content

Instantly share code, notes, and snippets.

@glyphobet
Created September 16, 2012 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glyphobet/3733407 to your computer and use it in GitHub Desktop.
Save glyphobet/3733407 to your computer and use it in GitHub Desktop.
jQuery.put() and jQuery.del() functions for HTTP PUT and DELETE methods
/* Extend jQuery with functions for PUT and DELETE requests. */
/* Based on http://homework.nwsnet.de/news/9132_put-and-delete-with-jquery */
(function(){
function _ajax_request(url, data, callback, type, method) {
if (jQuery.isFunction(data)) {
callback = data;
data = {};
}
return jQuery.ajax({
type: method,
url: url,
data: data,
success: callback,
dataType: type
});
}
jQuery.extend({
put: function(url, data, callback, type) {
return _ajax_request(url, data, callback, type, 'PUT');
},
del: function(url, data, callback, type) {
return _ajax_request(url, data, callback, type, 'DELETE');
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment