From 7f1dfc2b3874738cc456e6d009ca52de9800aa86 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Sun, 26 May 2013 09:15:21 +0100 Subject: [PATCH] Update: Provide link to technical note explaining errors for DT logged errors - A lot of posts in the forum are questions such as "what does the invalid JSON response" error mean, or "how to fix the unknown requested parameter error". To address these, rather than having them answered individually in the forum, I'm going to write a series of technical notes for DataTables (getting started, how to use columns etc) and as part of those, each error that DataTables can fire off will have a technical note explaining in deatil what the error means. - Example: DataTables warning: table id=example - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1 - This commit puts the required logic in place. The technical notes don't exist yet, but they will soon. They will be: 1 - Invalid JSON response 2 - Non-table node initialisation ({this.nodeName}) 3 - Cannot reinitialise DataTable 4 - Requested unknown parameter {param} for row {idx} 5 - Unknown paging action: {action} 6 - Possible column misalignment - The table cannot fit into the current element which will cause column - This also has the advantage that the errors in the DataTables code can be a little smaller. Around 500 bytes saved. - This fixes issue #173 --- media/src/core/core.ajax.js | 4 +- media/src/core/core.constructor.js | 7 +--- media/src/core/core.data.js | 4 +- media/src/core/core.page.js | 2 +- media/src/core/core.scrolling.js | 11 +----- media/src/core/core.support.js | 63 ++++++++++++++---------------- 6 files changed, 39 insertions(+), 52 deletions(-) diff --git a/media/src/core/core.ajax.js b/media/src/core/core.ajax.js index 321cb602..507c86de 100644 --- a/media/src/core/core.ajax.js +++ b/media/src/core/core.ajax.js @@ -50,7 +50,7 @@ function _fnBuildAjax( oSettings, data, fn ) if ( json.sError ) { oSettings.oApi._fnLog( oSettings, 0, json.sError ); } - + $(oSettings.oInstance).trigger('xhr', [oSettings, json]); fn( json ); }, @@ -59,7 +59,7 @@ function _fnBuildAjax( oSettings, data, fn ) "type": oSettings.sServerMethod, "error": function (xhr, error, thrown) { if ( error == "parsererror" ) { - oSettings.oApi._fnLog( oSettings, 0, "DataTables: invalid JSON response" ); + oSettings.oApi._fnLog( oSettings, 0, 'Invalid JSON response', 1 ); } } }; diff --git a/media/src/core/core.constructor.js b/media/src/core/core.constructor.js index 15354227..51c24fce 100644 --- a/media/src/core/core.constructor.js +++ b/media/src/core/core.constructor.js @@ -9,8 +9,7 @@ var oInitEmpty = oInit === undefined ? true : false; /* Sanity check */ if ( this.nodeName.toLowerCase() != 'table' ) { - _fnLog( null, 0, "Attempted to initialise DataTables on a node which is not a "+ - "table: "+this.nodeName ); + _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 ); return; } @@ -45,9 +44,7 @@ for ( i=0, iLen=DataTable.settings.length ; i