I have a problem that I do not know how to fix. I load a php page with ajax in a DIV and within that page I load some tables with ajax as well.
Everything here is correct and works but there is a problem, which is that I load the page and the tables are not loaded yet, it takes a few more seconds to shit, being with ajax that is asynchronous is normal. You need to load everything at once or wait for all the complete calls to be displayed.
I tried to put async: false in the flames of the tables, but it gives an error as if the Dom was not loaded. $ ("# midiv"). DataTable (datatable error is not function.
I have put where I call the load function of tables $ (document) .ready (function () to make sure that the DOM loads first, but not with those.
Then I do not know what's wrong or if I can delay the loading of the php page so that all the functions are finished.
I hope you understand, Thank you very much
Thanks for your response, but I still get the error.
crearTablaClienteGrafica : function (idCliente){
var objDatos;
$.ajax({
async: false,
type: "GET",
url: "/wordpress/gsc/formulario-clientes/php/acciones/estudioNegocio.php?metodo=dameTablaDatosCliente&idCliente="+idCliente,
contentType: "json",
success:function (datos) {
objDatos = JSON.parse(datos);
//estudio.pintarVistaTablas("/wordpress/gsc/formulario-clientes/componentes/compTablaCliente.php", "tablaCliente", objDatos);
}
}).done(function () {
estudio.pintarVistaTablas("/wordpress/gsc/formulario-clientes/componentes/compTablaCliente.php", "tablaCliente", objDatos);
});
pintarVistaTablas : function (vista, capa, datos){
$.ajax({
async: false,
type: "POST",
url: vista+"?datos="+datos,
contentType: "html",
success:function (html) {
$("#"+capa).html(html);
}
});
}
I have a function that calls a php and gives me all the data in the table and then I call the function paintVista that calls another php that creates the table that I paint later (it is in the second where the dataTable is called) . In asynchronous it works perfectly, but I would need it to be synchronous for what I explained above.
Thanks