I my jQuery code, I need to load some data in a DataTable, and then, do stuff only after this DataTable has been properly filled.
My code currently looks like :
function f () {
/* ... */
$('#my_datatable').DataTable().ajax.url(my_url).load();
/* Do some stuff */
}
f();
/* Do some more stuff */
And I want /* Do some stuff */ or /* Do some more stuff */ to be executed only after my DataTable is nicely displayed.
I am pretty new with javascript's asynchronicity, so I might misunderstand my needs, but I think I would like to do something like :
async function f () {
/* ... */
await $('#my_datatable').DataTable().ajax.url(my_url).load();
/* Do some stuff */
}
f().then (function () {
/* Do some more stuff */
});
This is what I usually do when I want to wait for a $.get() to be fully done.
Is there any way do do such kind of thing with DataTable's .ajax.url().load() ?