I was looking for the post and get code today (I'm planning on replicating them for the DELETE and PUT verbs... those should be added) and I noticed a funny problem with the following (GET has the same problem):
post: function( url, data, callback, type ) {
if ( jQuery.isFunction( data ) ) {
callback = data;
data = {};
}
return jQuery.ajax({
type: "POST",
url: url,
data: data,
success: callback,
dataType: type
});
},
You make a check to see if the second argument is a function, indicating that no data is being sent. That's fine but it ignores the fact that the type might also be passed. As a result, the following would have unintended effects:
$.post("/sample/test", do_stuff_function, "text/html");
It also doesn't take into account
$.post("/sample/test", "text/html");
Which, while probably silly in most cases, is legitimate within the published docs for the functions.
I suspect the following would be a better solution (depending on how you feel about using arguments.length, you could use other methods to identify things):
if (arguments.length == 2 ) {
type = data;
callback = function () {};
data = {};
} else if (arguments.length == 3) {
type = callback;
callback = data;
data = {};
};