I have this code on test.php displays all contents from testfile2.php every 3 seconds. This works fine but all jquery & css links are not being seen whether they are in test.php or testfile2.php
function refresh()
{
var req = new XMLHttpRequest();
console.log("Grabbing Value");
req.onreadystatechange = function ()
{
if (req.readyState == 4 && req.status == 200)
{
document.getElementById('monitor').innerHTML = req.responseText;
}
}
req.open("GET", 'testfile2.php', true);
req.send(null);
}
function init()
{
refresh()
var int = self.setInterval(function ()
{
refresh()
}, 3000);
}
From looking at your code, it seems like testfile2.php will give back html code which you will use to insert into your current page with innerHTML. However doing so will not execute the javascript, you have to use eval() to execute any javascript returned
Check out the answer of similar question also Can scripts be inserted with innerHTML?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.