AJAX source never loads

AJAX source never loads

Taylor514ceTaylor514ce Posts: 74Questions: 8Answers: 0
edited May 2012 in DataTables 1.9
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]

Replies

  • snarf2larfsnarf2larf Posts: 64Questions: 0Answers: 0
    I'm not sure if you have to do this or not but in my AJAX implementation I followed the example here:

    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
  • Taylor514ceTaylor514ce Posts: 74Questions: 8Answers: 0
    Thank you. I did resolve this issue, which was a cross-domain issue. I use a variable that is replaced globally at run-time by my system, for the server URL and port. I had set it to 127.0.0.1 but initially loading the page with "localhost". Since localhost <> 127.0.0.1, the json data would not load.

    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.
This discussion has been closed.