From 7643a269b2697e7be29f65fe920d53db55421c09 Mon Sep 17 00:00:00 2001 From: noxhj Date: Wed, 11 Jun 2014 13:01:26 +0200 Subject: [PATCH] Add responseJSON attribute to JQueryXHR --- jquery/jquery-tests.ts | 3 +++ jquery/jquery.d.ts | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 81ddb3ae1..b0f5dfc9a 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -86,6 +86,9 @@ function test_ajax() { success: function (data) { $('.result').html(data); alert('Load was performed.'); + }, + error: function (jqXHR, textStatus, errorThrown) { + alert('Load ailed. responseJSON=' + jqXHR.responseJSON); } }); var _super = jQuery.ajaxSettings.xhr; diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 70a9532ab..bb5a73fd9 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -80,7 +80,7 @@ interface JQueryAjaxSettings { /** * A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and cross-domain JSONP requests. This is an Ajax Event. */ - error? (jqXHR: JQueryXHR, textStatus: string, errorThrow: string): any; + error? (jqXHR: JQueryXHR, textStatus: string, errorThrown: string): any; /** * Whether to trigger global Ajax event handlers for this request. The default is true. Set to false to prevent the global handlers like ajaxStart or ajaxStop from being triggered. This can be used to control various Ajax Events. */ @@ -168,6 +168,10 @@ interface JQueryXHR extends XMLHttpRequest, JQueryPromise { */ overrideMimeType(mimeType: string): any; abort(statusText?: string): void; + /** + * Property containing the parsed response if the response Content-Type is json + */ + responseJSON: any; } /**