I am using dataTable.net plugin to draw a table on my html page, It is working fine. I want to execute a function say xyz() which contains a ajax call (ajax call also executing as I want). Before drawing the table I want to execute xyz() function, but it is first drawing table and then executing the function.
I am calling xyz() as
$(function () {
xyz();
// dataTable.net code.
});
xyz()
{
$.ajax(
{
// some code
});
}
Actually, I am fetching some data from server, and trying to render it to the dataTable.net
but dataTable.net is drawing table first and after the ajax call is getting complete, though I am calling ajax before dataTable.net.
Please help me.
I am not sure, but I think JavaScript is not waiting for the ajax to complete means getting back with some data, it is just going on. I think, it is just executing the ajax function and moving further.
For now I managed it by drawing dataTable in ajax’s success, If any one can improve it, please edit it.