2

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);
}
NappingRabbit
  • 1,888
  • 1
  • 13
  • 18
Gino
  • 189
  • 2
  • 10

1 Answers1

0

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?