Problem with loading JSON data

Problem with loading JSON data

ivanovtivanovt Posts: 5Questions: 0Answers: 0
edited September 2011 in General
Hello,

I'm using DataTable 1.8.1 and I have a very strange problem with displaying data loaded from the server.
I have XAMPP on my laptop with PHP 5.3.5 and I use jquery.ui.tabs (1.5.1) on my web page. A table is displayed each time when a tab is selected.
And it looks and works really good.
Than I copied all the sources onto an other pc. There is also an XAMPP installed, but with a PHP 5.2.9. And in this case the header of my table, the pagination buttons and the search field are rendered well, but the table contains no data (only my hardcoded row: "No data was loaded!") and the text "Processing..." can be seen under the table.

I tried it with a table using hard coded data in it and it works good in both cases.
And we have another application with a DataTable (1.6.2) server side processing but without tabs and it also works good in both cases.

I have really no idea what the problem can be.
Do you think, that it's possible that the server side processing of the DataTable 1.8.1, when the table is used on a jquery.ui.tab panel, doesn't work with PHP 5.2.9?

My source code:
$('#tbl_swv').dataTable({
bProcessing: true,
bServerSide: true,
sAjaxSource: "../tswversion/tswversionlist_ajax.php",
fnServerData: function(sSource, aoData, fnCallback) {
$.ajax({
dataType: "json",
type: "POST",
url: sSource,
data: aoData,
success: fnCallback
});
},
aoColumns: [
{ "sType": "html", "sWidth": "1%", "bSortable": false, "sClass": "editStart" },
{ "sType": "html", "sWidth": "16%" },
{ "sType": "html", "sWidth": "26%" },
{ "sType": "html", "sWidth": "15%" },
{ "sType": "html", "sWidth": "16%" },
{ "sType": "html", "sWidth": "5%" },
{ "sType": "html", "sWidth": "16%" },
{ "sType": "html", "sWidth": "2%" },
{ "sType": "html", "sWidth": "2%", "bSortable": false },
{ "sType": "html", "sWidth": "1%", "bSortable": false }
],
sDom: '<"top"pfil>t<"bottom"ip>r',
bAutoWidth: false,
iDisplayLength: 25,
aaSorting: [[ 1, "asc"]],
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
$('a', nRow).click(function() {
$('#tabsData').tabs( "url" , tabNr, this.href );
$.post(this.href, function(data){
$('#tabsData').tabs('load', tabNr);
});
var newTitle= "* "+$('#tabsData ul:first li:eq('+tabNr+') a').text();
$('#tabsData ul:first li:eq('+tabNr+') a').text(newTitle);
return false;
});
return nRow;
});






Name
Description
Remarks
Entity
Date
DevRep
S
Lib.





No data was loaded!

Replies

  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    What does the JSON return from the server look like? You can see it using Firebug or Inspector.

    Allan
  • ivanovtivanovt Posts: 5Questions: 0Answers: 0
    Hi Allan,

    here is another example with non-sensitiv data from the database:
    $('#tbl_qos').dataTable({
    bProcessing: true,
    bServerSide: true,
    sAjaxSource: "../tswversion/qos_ajax.php",
    fnServerData: function(sSource, aoData, fnCallback) {
    $.ajax({
    dataType: "json",
    type: "POST",
    url: sSource,
    data: aoData,
    success: fnCallback
    });
    },
    aoColumns: [
    { "sType": "html", "sWidth": "20%" },
    { "sType": "html", "sWidth": "30%" },
    { "sType": "html", "sWidth": "50%" }
    ],
    sDom: '<"top"pfil>t<"bottom"ip>r',
    bAutoWidth: false,
    iDisplayLength: 10,
    aaSorting: [[ 1, "asc"]]
    });




    Name
    Value
    Description




    No QoS data was found!




    JSON:
    {"iTotalRecords":"21",
    "iTotalDisplayRecords":"21",
    "sEcho":1,
    "aaData":[
    ["be","00000000","Besteffort"],
    ["cs1","00100000","Class Selector1"],
    ["af11","00101000","Assured Forwarding Low Drop Prec (Class1)"],
    ["af12","00110000","Assured Forwarding Medium Drop Prec (Class1)"],
    ["af13","00111000","Assured Forwarding High Drop Prec (Class1)"],
    ["cs2","01000000","Class Selector 2"],
    ["af21","01001000","Assured Forwarding Low Drop Prec (Class 2)"],
    ["af22","01010000","Assured Forwarding Medium Drop Prec (Class 2)"],
    ["af23","01011000","Assured Forwarding High Drop Prec (Class 2)"],
    ["cs3","01100000","Class Selector3"]
    ]
    }
  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    The looks like it should work quite well to me. I don't see a problem with the data being given. Are you able to link us to an example?

    Allan
  • ivanovtivanovt Posts: 5Questions: 0Answers: 0
    ... yes and it works on an other computer very well!
    Unfortunately I can't link you to an example. So I keep on trying to find out what's happenening in case of php 5.2.9.

    Anyway, thank you very much for trying to help me in such an incomprehensible problem!

    Timea
  • ivanovtivanovt Posts: 5Questions: 0Answers: 0
    edited September 2011
    I just realized something in the firebug.
    I can't see there what JSON sends back from the server.
    If I check the post data under console->all log entries there is only Headers, Post, Request and HTML info available but no JSON. As I can see on the other computer where it works, I should see there JSON as a separate tab.

    Timea
This discussion has been closed.