Addeventlistener with ajax not working well

The second argument to addEventListener should be a function. You’re not passing a function, you’re calling the function immediately and passing the result. Change to:

document.getElementById("showF").addEventListener("click", function() {
    sacardatos('P1.txt','container');
}, false);

Leave a Comment