From a6d7470f12261f0359e31aa2bcb53a3542273d7f Mon Sep 17 00:00:00 2001 From: Junle Li Date: Tue, 10 Jun 2014 23:30:45 +0800 Subject: [PATCH] Add jQuery.ajax test to verify a bug. The definition does not leverage the returned value of $.ajax() method well. The official syntax is ``` jqXHR.then(function( data, textStatus, jqXHR ) {}, function( jqXHR, textStatus, errorThrown ) {}); ``` (From: http://api.jquery.com/jQuery.ajax/) --- jquery/jquery-tests.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 79dda3e54..30cb2111a 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -150,6 +150,15 @@ function test_ajax() { url: "test.js", dataType: "script" }); + + // treat $.ajax() as a promise (as of 1.8) + $.ajax({ + url: "test.js" + }).then((data, textStatus, jqXHR) => { + console.log(data, textStatus, jqXHR); + }, (jqXHR, textStatus, errorThrown) => { + console.log(jqXHR, textStatus, errorThrown); + }); } function test_ajaxComplete() {