diff options
author | John Resig <jeresig@gmail.com> | 2009-12-06 17:17:14 -0800 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2009-12-06 17:17:14 -0800 |
commit | fbc73d45b487dd863886c7fd3f0af1fd4dec261b (patch) | |
tree | de809af3d341e256b6035fbc8c4052c87ae1a895 /test | |
parent | aea5b091954b3c823b318b392660b22c7b1e978a (diff) | |
download | jquery-fbc73d45b487dd863886c7fd3f0af1fd4dec261b.tar.gz jquery-fbc73d45b487dd863886c7fd3f0af1fd4dec261b.zip |
Added in support for $.ajax jsonpCallback (allowing you to specify the name of the callback method - and allowing you to avoid skipping the cache). Fixes #4206.
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/ajax.js | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js index d827a1530..4d63ce5a6 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -518,10 +518,10 @@ test("jQuery.getScript(String, Function) - no callback", function() { }); test("jQuery.ajax() - JSONP, Local", function() { - expect(7); + expect(8); var count = 0; - function plus(){ if ( ++count == 7 ) start(); } + function plus(){ if ( ++count == 8 ) start(); } stop(); @@ -580,6 +580,20 @@ test("jQuery.ajax() - JSONP, Local", function() { }); jQuery.ajax({ + url: "data/jsonp.php", + dataType: "jsonp", + jsonpCallback: "jsonpResults", + success: function(data){ + ok( data.data, "JSON results returned (GET, custom callback name)" ); + plus(); + }, + error: function(data){ + ok( false, "Ajax error JSON (GET, custom callback name)" ); + plus(); + } + }); + + jQuery.ajax({ type: "POST", url: "data/jsonp.php", dataType: "jsonp", @@ -624,6 +638,22 @@ test("jQuery.ajax() - JSONP, Local", function() { }); }); +test("JSONP - Custom JSONP Callback", function() { + expect(1); + stop(); + + window.jsonpResults = function(data) { + ok( data.data, "JSON results returned (GET, custom callback function)" ); + start(); + }; + + jQuery.ajax({ + url: "data/jsonp.php", + dataType: "jsonp", + jsonpCallback: "jsonpResults" + }); +}); + test("jQuery.ajax() - JSONP, Remote", function() { expect(4); |