1.9. Make sure the server is finishedRight now, your updatePage() function assumes that the server is finished when it runs... but that's not the case! To understand what's going on with your request, it's time to learn about ready states . Your request object has a ready state that tells the browser quite a bit about what state the request is in. These are the request's ready states. Web BrowserHere, the connection is just getting initialized. Internet ExplorerAll done! The server's response is ready to be used. Firefox Opera Safari Mozilla PHP scriptNow the request is being worked on... Request ResponseThe server's almost finished with the request now. A ready state tells the browser what stage a request is in. 1.9.1. Ready states are connected to your request object's onreadystatechange propertyDo you remember the property you used in getBoardsSold() to tell the browser what to do when the server sent back a response? Take a look to refresh your memory: function getBoardsSold() { createRequest(); var url = "getUpdatedBoardSales-ajax.php"; request.open("GET", url, true); request.onreadystatechange = updatePage;This property sets the function that the browser should run every time that the request's ready state changes.This property affects every ready state, not just the one indicating that the server is finished with a request. request.send(null); } |