From 62b9dbd1bf5b1165f593553d90e37796ecfbbfad Mon Sep 17 00:00:00 2001 From: knuton Date: Wed, 15 Sep 2010 13:18:17 +0200 Subject: [PATCH] Add test and fix for unset request type --- cross-domain-ajax/jquery.xdomainajax.js | 4 ++-- cross-domain-ajax/test/test.js | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/cross-domain-ajax/jquery.xdomainajax.js b/cross-domain-ajax/jquery.xdomainajax.js index a41154b..f07175f 100644 --- a/cross-domain-ajax/jquery.xdomainajax.js +++ b/cross-domain-ajax/jquery.xdomainajax.js @@ -26,7 +26,7 @@ jQuery.ajax = (function(_ajax){ var url = o.url; - if ( /get/i.test(o.type) && !/json/i.test(o.dataType) && isExternal(url) ) { + if ( (typeof o.type === 'undefined' || /get/i.test(o.type)) && !/json/i.test(o.dataType) && isExternal(url) ) { // Manipulate options so that JSONP-x request is made to YQL @@ -72,4 +72,4 @@ jQuery.ajax = (function(_ajax){ }; -})(jQuery.ajax); \ No newline at end of file +})(jQuery.ajax); diff --git a/cross-domain-ajax/test/test.js b/cross-domain-ajax/test/test.js index 1901b5f..78b36d1 100644 --- a/cross-domain-ajax/test/test.js +++ b/cross-domain-ajax/test/test.js @@ -1,9 +1,6 @@ -test('GET', function(){ - - expect(1); - stop(); +asyncTest('GET', 1, function(){ jQuery.get('http://google.com', function(res){ ok( @@ -13,4 +10,18 @@ test('GET', function(){ start(); }); -}); \ No newline at end of file +}); + +asyncTest('Implicit GET', 1, function(){ + + jQuery.ajax({ + url: 'http://yahoo.com', + success: function(res){ + start(); + ok( + !!(res && res.responseText), + 'Implicit GET Request to Google.com succeeded!' + ); + } + }); +});