Why does multiple simultaneous server side processing requests cause json failure?

Why does multiple simultaneous server side processing requests cause json failure?

BenjaminBenjamin Posts: 5Questions: 0Answers: 0
edited November 2011 in Bug reports
I integrated DataTables with cakephp (horrible stucture), but it works correctly most of the time.

Basically I have 3 to 10 tables on a page, created off of a single select query, and when the page loads it runs the request multiple times without error.

And then I use:
[code]
queue1.fnReloadAjax();
queue2.fnReloadAjax();
[/code] ect.

to repopulate the data every 85 seconds for each table.

But sometimes my one table takes longer to populate than 85 (or someone starts a search), then I get the json formatting falure.
This cannot be correct since the data originally populates from there and sometimes goes through without a problem with the ajax refresh.

Could this be due to $_GET or $_POST variables that change while running script? (I think I am using get variables)

Is this a bug? Is there a way to prevent this from happening?

Replies

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    If you are getting a JSON formatting error, I'd say that is the place to start. What does the JSON return look like in Firebug / Inspector when you do get that error?

    The code you have above should work just fine (although note that if you are using server-side processing you should just use fnDraw rather than fnReloadAjax).

    Allan
  • BenjaminBenjamin Posts: 5Questions: 0Answers: 0
    edited November 2011
    Thanks for the reply, I somehow with luck, got my Director off of the Idea of server side processing with data-tables.

    It runs very slowly compared to having data-tables running from pure html.

    I still ajax the data every interval (2 mins at the moment), but I destroy existing data-tables before the ajax, and reinitialize data-tables on the new html (this prevent errors when trying to redirect or refresh while an ajax request was running).

    Interestingly side note:
    I had very large html tag count due to the tables fully loading before data-tables trim it down to the default 10. Due to this the page loaded 10-15 seconds before the DOM was ready.
    I then decided to hide (div display:none) the content of the tables, load datatables on the "hidden" tables and then show the tables on DOM ready (div display:block).

    This changed the loading time from 10-15 seconds to less than 2 seconds. This is on more than 12 thousand lines of view source code.
This discussion has been closed.