I have a problem with jquery's load() function.
When I click the button the first time, the page loads,
When I click it a second time, I load the page twice (seen in the debugger, network section).
When I click it for the third time, the page loads three times
So on, making the page take too long to load.
The scripts that I have on the page that loads (ver-ente.php) are also executed since they are in a $(document).ready().
the load(), is executed from the .content-inner
$(document).on("click", ".ver-detalles", function() {
id_ente = $(this).attr("id-ente");
CargarContenido('vistas/ver-ente.php', 'content-inner');
});}
here is the function
function CargarContenido(pagina_php, contenedor) {
$("." + contenedor).load(pagina_php);
}
Why it happens? How to avoid it?
Thanks for your time.
I'm almost sure it's a
twice event firing
you can fix it with:I would recommend the use of namespace in the events,
.ic
actually it is any text to differentiate the type of click that you want to manipulate...I tried the function ArcanisGK507 gave me , and I'm left with this line:
Finally my code looks like this:
On the other hand, I was digging in the jquery documentation, and it also serves the function
one()
that is just as effective to solve the overload of files.The problem is solved with the following code: