Skip to content

Instantly share code, notes, and snippets.

@tobym
Created May 2, 2009 23:58
Show Gist options
  • Select an option

  • Save tobym/105754 to your computer and use it in GitHub Desktop.

Select an option

Save tobym/105754 to your computer and use it in GitHub Desktop.
jQuery PUT and DELETE requests
/* Extend jQuery with functions for PUT and DELETE requests. */
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');
},
delete_: 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