Every time I try to open my javascript file i get this error on Line: 1 Char: 1 Error: 'window' is undefined Code: 800A1391 Source: Microsoft JScript runtime error
My code is a simple html file, a javascript js file, and a json file. The html and json file opens up but the javascript does not. also the javascript is supposed to make the info in the json file appear on the html page but it does not
this is the javascript
window.onload = function() {
var url = "file:///C:/wamp/www/gumball/sales.json";
var request = new XMLHttpRequest();
request.open("GET", url);
request.onload = function() {
if (request.status == 200) {
updateSales(request.responseText);
}
};
request.send(null);
}
function updateSales(responseText) {
var salesDiv = document.getElementById("sales");
salesDiv.innerHTML = responseText;
}
Comments
Leave a comment