I load entire page html with ajax call, display it with document.write and then I do some modification. I need to use document.write to load elements in the right order in the same way as it was loaded by visiting the page. Everything works fine, except on IE and Edge where setInterval doesn't work.
My code:
var my_module = {
loadPage: function(){
var url = window.location.origin;
$.ajax({
type: "GET",
url: url
}).done(function(data) {
document.write(data);
document.close();
my_module.example()
});
},
example: function(){
alert(1) //this works fine
var waitForElement = setInterval(function(){
alert(5) //this won't work in IE or edge
},2000)
},
}
my_module.loadPage();
In other browsers I receive alert, but not in IE and Edge. What is the reason for that and is there any solution for it?