Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WETness getting you down? Fear not, the $.get and $.post methods are …
…now 866% DRYer. This fixes #7847.
  • Loading branch information
cowboy committed Dec 26, 2010
1 parent 52b1709 commit 1830db4
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions src/ajax.js
Expand Up @@ -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.toLowerCase() ] = function( url, data, callback, type ) {
// shift arguments if data argument was omited
if ( jQuery.isFunction( data ) ) {
type = type || callback;
Expand All @@ -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");
Expand All @@ -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 );
},
Expand Down

3 comments on commit 1830db4

@jzaefferer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who let that punk in here with his funky commit message?

@cowboy
Copy link
Member Author

@cowboy cowboy commented on 1830db4 Dec 27, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just paying respect to jQuery 1.2.6, of course.

@jaubourg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was so cavalier only a cowboy could do it! ;)

Please sign in to comment.