fnDraw() and "Processing...."
fnDraw() and "Processing...."
Alan,
I am refreshing a table's AJAX / JSON via oTable.fnDraw() . The ""Processing...." message persists.
This only occurs after the "refresh", not the initial successful AJAX load.
Any ideas as to why this would be?
Shameless
I am refreshing a table's AJAX / JSON via oTable.fnDraw() . The ""Processing...." message persists.
This only occurs after the "refresh", not the initial successful AJAX load.
Any ideas as to why this would be?
Shameless
This discussion has been closed.
Replies
Sounds like your JSON that you are reloading is not valid. If you run it through http://jsonlint.com is it okay? Failing that, any JS errors or any other indications of anything?
Regards,
Allan
This is the JSON that "succeeds" upon initialization:
[code]
{"sEcho": 1,"iTotalRecords": 2,"iTotalDisplayRecords": 2,"aaData": [ [ "8","","25","February 24, 2010 - 11:21 AM","February 26, 2010 - 02:41 PM","1.00","Yes","11","71957","March 3, 2010 - 11:21 AM"], [ "11","","1000","February 26, 2010 - 02:18 PM","February 26, 2010 - 02:41 PM","1.00","Yes","11","71957","March 5, 2010 - 02:18 PM"] ]}
[/code]
JSLint: "JSON: good."
And this is the JSON after attempting a re-load via fnDraw() and getting the persistent "Processing...." status and no change in the loaded rows:
[code]
{"sEcho": 1,"iTotalRecords": 2,"iTotalDisplayRecords": 2,"aaData": [ [ "8","","25","February 24, 2010 - 11:21 AM","February 26, 2010 - 02:41 PM","1.00","Yes","11","71957","March 3, 2010 - 11:21 AM"], [ "11","","1000","February 26, 2010 - 02:18 PM","February 26, 2010 - 02:41 PM","1.00","Yes","11","71957","March 5, 2010 - 02:18 PM"] ]}
[/code]
JSLint: "JSON: good."
(This is just one sample of four DataTables that all exhibit the same behaviour.)
They appear to be the identical results to me and I have no idea why one would load successfully and dispense with the "Processing...." message as expected and the subsequent loads would NOT load and keep "Processing..."
BTW, is there anyway to see the results of the aaData via Firebug or to return / alert it upon the fnDraw() request so that I can the entire array that I am loading? I am generating the results above by calling the AJAX request directly by the address.
Thank you for your attention, sir.
Shameless
Firebug should show you the XHR go out and come back in, and that will show you the string that is returned from the server. An alternative would be to console.dir() in fnServerData.
Regards,
Allan
SOLVED--tia
*******************************
Alan,
I think I "get it" conceptually, but obviously I am making a mistake. I am using http://datatables.net/usage/server-side as my example
[code]
oTable.push($('#'+sid).dataTable( {
"bPaginate": false,
"bLengthChange": false,
"bJQueryUI": true,
"bServerSide": true,
"bProcessing": true,
"bAutoWidth": false,
"asStripClasses": [ 'alt1', 'alt2' ],
/* AJAX SOURCE */ "sAjaxSource": sAJx,
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
"aoColumns": [
/* id */ { "bVisible": false },
/* icon */ { "fnRender": function ( oObj ) {
var shtml= oObj.aData[0];
if(isNumber(shtml)){
var sspan = "";
return sspan;
}
} },
/* Quantity*/null,
/* Origin Date*/null,
/* Filled Date*/null,
/* Bid*/null,
/* Partial*/null,
/* Trans*/{ "bVisible": false },
/* InZIP*/null,
/* Expires*/null
]
} ));
[/code]
Q: Do I need to set "sSource" in the line "url": sSource," to a value or is it's value inherited from "sAjaxSource" in the preceding parameter?
Q: Does "aoData" have to be set in "data": aoData, " ? If it is not set, should this line be present? Same for ""success": fnCallback"?
Lastly, I am trying to retrieve and return the value of sEcho via this PHP:
[code]
$outerJSON .= '{';
$outerJSON .= '"sEcho": '.$_POST["sEcho"].',';
$outerJSON .= '"iTotalRecords": '.count($results).',';
$outerJSON .= '"iTotalDisplayRecords": '.count($results).',';
[/code]
The response in Firebug is:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: sEcho
The relevant POST value was:
sEcho 1
I get the feeling that I am messing up the initialization, but all my experiments are yielding approximately the same results. Sorry to be a bother.
Shameless
I see you've got a 'solved' note in your post - are you happy with how this works now? Or any outstanding questions still?
Allan