I'm on the gumball chapter and I've been trying for hours and I can't get this to work.
In google chrome I get this error..
XMLHttpRequest cannot load http://www.dreamofsl...all/sales.json. Origin http://dreamofsleeping.co.uk is not allowed by Access-Control-Allow-Origin.
I peaked ahead in the book past the cliffhanger, but it says I should be alright if both files on on the same server.
I tried the code in firefox and used the console, and I get this...
[15:04:56.447] GET http://www.dreamofsl...ball/sales.json [HTTP/1.1 200 OK 188ms]
200 means everything is OK right? But still nothing happens. I have commented out the code in the updateSales method and use an alert box instead. ONCE this worked. But then I changed something and it has never worked again.
Also is there a reason Firefox takes so long to display alterations in my source code? I upload new versions to my website, and it still displayed the old source code. Which is making this even more frustrating trying to figure out.
Here is my code. Maybe I'm just missing something really stupid. I haven't added the css file yet, as I don't see the need.
Thanks for any help. I really don't want to continue with this chapter until I get this sorted out.
<!doctype html>
<html lang="en">
<head>
<title>Mighty Gumball (JSON)</title>
<meta charset="utf-8">
<script src="mightygumball.js"></script>
</head>
<body>
<h1>Mighty Gumball Sales</h1>
<div id="sales">
</div>
</body>
</html>
//testing 2
window.onload = function() {
var url = "http://www.dreamofsleeping.co.uk/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) {
alert("in update sales");
// var salesDiv = document.getElementById("sales");
// salesDiv.innerHTML = "ResponseText = " + responseText;
}











