Two Tables: One Ajax Source

Two Tables: One Ajax Source

randyesqqrandyesqq Posts: 2Questions: 0Answers: 0
edited June 2013 in DataTables 1.9
I have searched around and have not found this scenario come up so I am posting to see if anyone else knows what to do. Bascially I have two tables on the same page and one ajax call that supplies the data for both of them. The data looks like this:

[code]
data['test'] = {'aaData': [ .... lots of data .... ]
data['protocol'] = {'aaData': [ .... lots of other data .... ]
[/code]

The server sends data for both of the tables because the backend code to create the 'test' and the 'protocol' is reused heavily and no one will need only one portion. Both need to be delivered.

I have always used sAjaxSource, even with multiple tables, but in those cases, the URLs were different and obviously the data was separate. I would like to know if there is a way to fetch the data via ajax and then split it out so each tables gets the right data.

Thanks!

Replies

  • aaronwaaronw Posts: 89Questions: 3Answers: 4
    I would suggest using $jquery.ajax to do the ajax get, then splitting that up into 2 arrays via javascript in the callback from that function, and then initializing the datatables instances based on those 'local' javascript arrays/objects.
  • randyesqqrandyesqq Posts: 2Questions: 0Answers: 0
    Thanks aaronw. Is there anyway that I can still get bProcessing to work?
This discussion has been closed.