Say I have the following code:
<div id="dashboard">
Loading Dashboard.....
</div>
<script>
var xhttpDashboard = new XMLHttpRequest();
xhttpDashboard.onreadystatechange = function() {
if (xhttpDashboard.readyState == 4 && xhttpDashboard.status == 200) {
document.getElementById("dashboard").innerHTML = xhttpDashboard.responseText;
}
};
xhttpDashboard.open("GET", "https://www.example.com/getdashboard.html", true);
xhttpDashboard.send();
</script>
getdashboard.html returns html which in turn contains more javascript XMLHttpRequest to be executed. I am finding these 2nd sets of XMLHttpRequests are not executing.
How can I get the 2nd set of javascript to execute?
Update Found this article to be useful: https://24ways.org/2005/have-your-dom-and-script-it-too