How Ajax Is Asynchronous
An XMLHttpRequest (XHR) object is used by web browser scripting
languages to pass data between the client and server asynchronously.
The basic procedure (in JavaScript):
- Create a new XHR object, call it xhr (unfortunately, this is not
browser independent)
- Give xhr a callback function to inform the client about the
status of its (impending) request to the server
- Give xhr a URL that you want to be accessed on the server
- Open and send a request for that URL through xhr
xhr acts as a go-between for the server and client:
- After the request is sent, xhr repeatedly invokes the callback
function
- The callback function can monitor the request's progress by
polling xhr.
Here is the full
showDateAndTime() function.