X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=c6557f4edc77e276bd8e5caaea0f429edeceb4e6;hb=77bb2c505f1d2c4437f4b52866408f8bd1a5020f;hp=c231673b3b399da09c99ff050c4938571fcec2d8;hpb=06c2f06a2183ef17a8119ef25a383a02572c0b55;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index c231673..c6557f4 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -136,6 +136,27 @@ test("$.ajax - beforeSend", function() { }); }); +test("$.ajax - beforeSend, cancel request (#2688)", function() { + expect(2); + var request = $.ajax({ + url: url("data/name.html"), + beforeSend: function() { + ok( true, "beforeSend got called, canceling" ); + return false; + }, + success: function() { + ok( false, "request didn't get canceled" ); + }, + complete: function() { + ok( false, "request didn't get canceled" ); + }, + error: function() { + ok( false, "request didn't get canceled" ); + } + }); + ok( request === false, "canceled request must return false instead of XMLHttpRequest instance" ); +}); + var foobar; test("$.ajax - dataType html", function() { @@ -449,7 +470,7 @@ test("$.ajax() - JSONP, Local", function() { $.ajax({ url: "data/jsonp.php", dataType: "jsonp", - data: { callback: "?" }, + jsonp: "callback", success: function(data){ ok( data.data, "JSON results returned (GET, data obj callback)" ); plus(); @@ -492,7 +513,7 @@ test("$.ajax() - JSONP, Local", function() { $.ajax({ type: "POST", url: "data/jsonp.php", - data: { callback: "?" }, + jsonp: "callback", dataType: "jsonp", success: function(data){ ok( data.data, "JSON results returned (POST, data obj callback)" ); @@ -558,7 +579,7 @@ test("$.ajax() - JSONP, Remote", function() { $.ajax({ url: base + "data/jsonp.php", dataType: "jsonp", - data: { callback: "?" }, + jsonp: "callback", success: function(data){ ok( data.data, "JSON results returned (GET, data obj callback)" ); plus(); @@ -649,15 +670,15 @@ test("$.getJSON(String, Function) - JSON object", function() { }); }); -test("$.getJSON(String, Function) - Remote JSON object with assignment", function() { +test("$.getJSON(String, Function) - JSON object with absolute url to local content", function() { expect(2); var base = window.location.href.replace(/\?.*$/, ""); stop(); - $.getJSON(base + "data/json_assigned_obj.js", function() { - ok( typeof json_assigned_obj == "object", 'Check JSON loaded' ); - equals( json_assigned_obj.test, "worked", 'Check JSON obj.test' ); + $.getJSON(url(base + "data/json.php"), function(json) { + ok( json.data.lang == 'en', 'Check JSON: lang' ); + ok( json.data.length == 25, 'Check JSON: length' ); start(); }); });