X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=c6557f4edc77e276bd8e5caaea0f429edeceb4e6;hb=2efd0b4cc5cce9b22cd4bc638e25cc998736b6e7;hp=8dcf7591e65b6385e8d767911d48db3715230c38;hpb=b721a2f472b53fec28276d2080d741cf070b686d;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 8dcf759..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() { @@ -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(); }); });