From 2a9068fead0e7263ea6ecc38739b4c7e0ec2d21b Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Fri, 27 May 2011 19:05:35 +0100 Subject: [PATCH] New: The object returned by $.ajax is assigned to jqXHR in the table's settings object now. This means that you can access the XHR in fnDrawCallback (or any of the other callback functions, or anything with access to the settings object!) to do further data manipulation if you wish. --- media/js/jquery.dataTables.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 73bfd017..e9982fa0 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -1319,13 +1319,21 @@ */ this.bAjaxDataGet = true; + /* + * Variable: jqXHR + * Purpose: The last jQuery XHR object that was used for server-side data gathering. + * This can be used for working with the XHR information in one of the callbacks + * Scope: jQuery.dataTable.classSettings + */ + this.jqXHR = null; + /* * Variable: fnServerData * Purpose: Function to get the server-side data - can be overruled by the developer * Scope: jQuery.dataTable.classSettings */ - this.fnServerData = function ( url, data, callback ) { - $.ajax( { + this.fnServerData = function ( url, data, callback, settings ) { + settings.jqXHR = $.ajax( { "url": url, "data": data, "success": callback, @@ -2412,7 +2420,7 @@ _fnProcessingDisplay( oSettings, false ); _fnInitComplete( oSettings, json ); - } ); + }, oSettings ); return; } @@ -3473,7 +3481,7 @@ oSettings.fnServerData.call( oSettings.oInstance, oSettings.sAjaxSource, aoData, function(json) { _fnAjaxUpdateDraw( oSettings, json ); - } ); + }, oSettings ); return false; } else