AJAX source never loads
AJAX source never loads
Taylor514ce
Posts: 74Questions: 8Answers: 0
I cannot get AJAX working. When I reference a static json.txt file, it works:
[code]
<!DOCTYPE html>
Test
$(document).ready(function() {
$('#box-table-a').dataTable( {
"bProcessing": true,
"sAjaxSource": "htmlFiles/myLog.txt"
} );
} );
body{ font: 62.5% "Trebuchet MS", sans-serif; margin: 15px;}
StatusProcessTimeMessageSort No.
[/code]
When I change the sAjazxSource to a web URL which creates and serves the "myLog.txt", I get the "Processing" message forever. I have checked the format of my json data, in fact, posting the URL directly in my browser and copying and pasting the result into notepad is how I generated the static version referenced above. That proved two things to me 1) the json-generating program is active and correct and 2) produces proper jason.
[code]
{ "aaData": [
["","logDisplay","05/29/2012 08:43:24 ","New log started.","0000000"]
,["","ltr","05/29/2012 10:00:57 AM","Job Started.","3605795"]
,["","ltr","05/29/2012 10:01:01 AM","Folder Cleanup.","3606114"]
,["","ltr","05/29/2012 10:01:03 AM","Archiving FilesIn.","3606327"]
] }
[/code]
[code]
<!DOCTYPE html>
Test
$(document).ready(function() {
$('#box-table-a').dataTable( {
"bProcessing": true,
"sAjaxSource": "htmlFiles/myLog.txt"
} );
} );
body{ font: 62.5% "Trebuchet MS", sans-serif; margin: 15px;}
StatusProcessTimeMessageSort No.
[/code]
When I change the sAjazxSource to a web URL which creates and serves the "myLog.txt", I get the "Processing" message forever. I have checked the format of my json data, in fact, posting the URL directly in my browser and copying and pasting the result into notepad is how I generated the static version referenced above. That proved two things to me 1) the json-generating program is active and correct and 2) produces proper jason.
[code]
{ "aaData": [
["","logDisplay","05/29/2012 08:43:24 ","New log started.","0000000"]
,["","ltr","05/29/2012 10:00:57 AM","Job Started.","3605795"]
,["","ltr","05/29/2012 10:01:01 AM","Folder Cleanup.","3606114"]
,["","ltr","05/29/2012 10:01:03 AM","Archiving FilesIn.","3606327"]
] }
[/code]
This discussion has been closed.
Replies
http://datatables.net/release-datatables/examples/server_side/server_side.html
Specifically makes sure you set "bServerSide" to true and that your server response is also responding with sEcho, iTotalRecords & iTotalDisplayRecords along with your aaData.
You can see details about these responses here:
http://datatables.net/usage/server-side
That's my theory, in any case. So long as the value I enter as the initial URL exactly matches the value of the variable for my server, it works.