Peter Bissmire

Communications & Language Services

Technical and general translations, French/German -> English

XMLHttpRequest

Apparently, this is the core of AJAX — but then, they invent acronyms for everything these days.
Most of us just look for ways of doing what we want to do and say "ta!" for the method that does it.
Making javaScript do something useful is more important than speaking the jargon.

According to w3schools, "The XMLHttpRequest object is a developer's dream..." (missing apostrophe supplied).
It can certainly be used to liven things up.
Since its purpose is to make http requests in the background, it can even post information without your noticing.
Great for processing forms but it is also the nearest javaScript comes to being insecure.
An example of a potentially "unpleasant" use would be to send a complete site navigation history back to the server.
User tracking with knobs on!
Its implementation for loading and refreshing content here looks like this:

.
var myGet = new XMLHttpRequest();
myGet.onreadystatechange = function() {
//event handling procedure for asynchronous (don't make the script wait for completion) requests.
//With an event handler, you can specify what is to happen in some detail.
};
myGet.open("GET", fileName, true); //"true" for asynchronous request, can also add user(name) & password
myGet.setRequestHeader('Cache-Control', 'no-cache');
myGet.send();

To control cacheing, it is sufficient to send the request with a Cache-Control header.
no-cache forces cache validation with the server, i.e. check Last-Modified header and any Etags. More details

An alternative dirty (but legitimate) trick to force fetch from the server
is to append to fileName a query string containing a time stamp or random number as uniqueID.
Example:
...fileName + '?t=' + now, ...