Multiple tables, one Ajax source, different columns
Multiple tables, one Ajax source, different columns
mosley
Posts: 8Questions: 4Answers: 0
Refer to the link below. The first table has Name and Position columns, and the second table has Name and Salary columns - from one Ajax source. Is there an better way to do this?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Your method of loading works fine. Why look any further?
Are you basically asking if you have have it make the Ajax call only once? If so, there are two options:
$.ajax
) and then usedata
to pass the data into the tables (orrows.add()
if you want to use the API).data()
to get the data from it androws.add()
to add them to the second table.Allan
Yes, I am thinking to make the Ajax request only once. I figured this would be best. I am trying here (and learning), but definitely missing something.
Going with your second method (first table makes the request) - see the following two links below. The first example populates my second table, but the second example doesnt. I presume it has to do something with the JSON data being in the wrong format, but I cannot figure it out.
http://live.datatables.net/jesiroge/1/edit
http://live.datatables.net/konimude/2/edit
What am I missing?
Remember that Ajax is asynchronous! You would need to wait for the table1 data to be loaded before you can use it...
You can use the
initComplete
callback on the first table to do that.Allan
Ajax is asynchronous! You must state that a few does times in your documentation. Got it now. Thanks!