I have an ajax request outside the document.addEventListener('DOMContentLoaded'), and I was wondering if I could wait for the ajax request to be completed inside the EventListener (without async:false).
In other words, don´t fire a function inside the EventListener until the ajax request is fully done.
This is my code:
var a;
$.ajax({
t: "GET",
url: "file.php"
}).done(function(data){
a = data;
});
document.addEventListener('DOMContentLoaded', function() {
//Wait for ajax request to complete
someFunction(a);
});