Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

WETness getting you down? Fear not, the $.get and $.post methods are …

…now 866% DRYer. This fixes #7847.
  • Loading branch information...
commit aee6b776315ce4419a0a5eb344971ea042d8f6b7 1 parent 52b1709
@cowboy cowboy authored committed
Showing with 7 additions and 22 deletions.
  1. +7 −22 src/ajax.js
View
29 src/ajax.js
@@ -113,9 +113,8 @@ jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".sp
};
});
-jQuery.extend({
-
- get: function( url, data, callback, type ) {
+jQuery.each( [ "get", "post" ], function( i, method ) {
+ jQuery[ method ] = function( url, data, callback, type ) {
// shift arguments if data argument was omited
if ( jQuery.isFunction( data ) ) {
type = type || callback;
@@ -124,13 +123,16 @@ jQuery.extend({
}
return jQuery.ajax({
- type: "GET",
+ type: method,
url: url,
data: data,
success: callback,
dataType: type
});
- },
+ };
+});
+
+jQuery.extend({
getScript: function( url, callback ) {
return jQuery.get(url, null, callback, "script");
@@ -140,23 +142,6 @@ jQuery.extend({
return jQuery.get(url, data, callback, "json");
},
- post: function( url, data, callback, type ) {
- // shift arguments if data argument was omited
- if ( jQuery.isFunction( data ) ) {
- type = type || callback;
- callback = data;
- data = {};
- }
-
- return jQuery.ajax({
- type: "POST",
- url: url,
- data: data,
- success: callback,
- dataType: type
- });
- },
-
ajaxSetup: function( settings ) {
jQuery.extend( jQuery.ajaxSettings, settings );
},
Please sign in to comment.
Something went wrong with that request. Please try again.