Upgrading 1.6 to 1.7.4 troubles

Upgrading 1.6 to 1.7.4 troubles

thoththoth Posts: 6Questions: 0Answers: 0
edited November 2010 in General
Hi, I'm trying to upgrade from 1.6 to 1.7.4 and I have the problem here:
[code]
oTable = $('#example').dataTable( {
"bServerSide":false,
"sAjaxSource": '/tableFromJson/'+typeName+'FullList.txt'
[/code]

In 1.6 this code load table from cherrypy server. But in 1.7.4 request to server didn't sended.
DataTables is no more compatible with cherrypy?
Is there any way to pass the table as a string?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I would guess that the JSON the server is sending back isn't strictly valid JSON ( http://jsonlint.com to test your JSON). 1.7 uses jQuery 1.4's JSON parser which is strict, where as 1.6.x just used eval()...

    Allan
  • thoththoth Posts: 6Questions: 0Answers: 0
    Actually the problem is likely that the request is not sent to the server.
    It looks like the query isn't initiated on client side.
    Here is the snippet of the code on the server side. I don't get the print "tableFromJson" in my terminal.
    [code]
    @cherrypy.expose
    def tableFromJson(self, fileName="FullList.txt"):
    print "tableFromJson"
    return FileIO.FileIO().makeJson(fileName)
    [/code]

    In the former version (1.6) I've checked JSON sent back is valid following your validator
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Interesting. If you look at Firebug do you see the XHR being sent out? There shouldn't be anything that is different between the two which would stop this, and you can see sAjaxSource in action here: http://datatables.net/examples/data_sources/ajax.html . Any javascript errors in Firebug?

    Allan
  • thoththoth Posts: 6Questions: 0Answers: 0
    Here the XHR for 174:
    GET http://localhost:8080/tableFromJson/TrackingFullList.txt?_=1290155332333 405 Not Found
    With error: 'Unexpected query string parameters: _'
    Params: _ 1290155332333

    The same (working) output for 16:
    http://localhost:8080/tableFromJson/TrackingFullList.txt 200 Ok

    I think that the problems comes from a parameter.
  • thoththoth Posts: 6Questions: 0Answers: 0
    A small update: when I try to load table from a txt file, it fails in both version with error:
    The path '/TrackingFullListTable.txt' was not found.

    The file is present and readable by everyone:
    $ ls -l TrackingFullListTable.txt
    -rw-r--r-- Nov 18 14:43 TrackingFullListTable.txt
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    > With error: 'Unexpected query string parameters: _'

    Interesting! The web-server is objecting to the anti IE cache var that jQuery is putting on the XHR. I've not come across that before. What you can do is use fnServerData to construct an Ajax request (like this - http://datatables.net/examples/server_side/custom_vars.html - this is for server-side processing, but works for a normal sAjaxSource as well) to construct your own $.ajax request without the anti-IE cache.

    Out of interest, what web-server are you using?

    Allan
  • thoththoth Posts: 6Questions: 0Answers: 0
    [code]
    "fnServerData": function ( sSource, aoData, fnCallback ) {
    $.getJSON( sSource, aoData, function (json) {
    fnCallback(json)
    } );
    }
    [/code]

    Now it works)
    Thanks for the help.

    As server I use Cherrypy, a python library: http://www.cherrypy.org/
This discussion has been closed.