Answer to Question #5780 in Java | JSP | JSF for Johanni Thunstrom

Question #5780
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;
}
0
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS