From: Dan Heberden Date: Tue, 1 Feb 2011 03:37:28 +0000 (-0800) Subject: Bug 8107; Fix argument handling for $.ajax for multiple method signatues and add... X-Git-Url: http://git.asbjorn.it/?p=jquery.git;a=commitdiff_plain;h=31949fa528141dad4b92851212677b039cb23cfb Bug 8107; Fix argument handling for $.ajax for multiple method signatues and add test case --- diff --git a/src/ajax.js b/src/ajax.js index c7d7f2d..3158ca4 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -322,9 +322,8 @@ jQuery.extend({ // Main method ajax: function( url, options ) { - // If options is not an object, - // we simulate pre-1.5 signature - if ( typeof options !== "object" ) { + // If url is an object, simulate pre-1.5 signature + if ( typeof url === "object" ) { options = url; url = undefined; } diff --git a/test/unit/ajax.js b/test/unit/ajax.js index a536b9f..25e0218 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -2161,6 +2161,25 @@ test("jQuery.ajax - active counter", function() { ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active ); }); +test( "jQuery.ajax - multiple method signatures introduced in 1.5 ( #8107)", 4, function() { + + expect( 3 ); + + var i = 3; + + jQuery.ajaxSetup({success: function() { + ok( true, "Success"); + if ( ! --i ) start(); + }}); + + stop(); + jQuery.ajax('data/name.html'); + jQuery.ajax('data/name.html', {} ); + jQuery.ajax({ url: 'data/name.html'} ); + + jQuery.ajaxSetup({ success: null }); +}); + } //} \ No newline at end of file