I have been experimenting with AJAX in IE7. I noticed that IE7 now supports the XMLHttpRequest object so I thought I would give it a try. So say I take the following code (I removed all of the browser checking code in the getHTTPObject function to keep it simple)....
var xmlHttp;
function getHTTPObject()
{
return new XMLHttpRequest();
}
function xmlHttpGet( url, handler )
{
xmlHttp = getHTTPObject();
xmlHttp.onreadystatechange = handler;
xmlHttp.open( "GET", url );
xmlHttp.send();
}
function xmlHttpPost( url, sendItem )
{
xmlHttp = getHTTPObject();
xmlHttp.open( "POST", url );
xmlHttp.send( sendItem );
}
Running this code works fine for all of the POST calls. Running the GET works the first time. Every time I call it after the first, it doesn't call the server. It seems to return some cached value from the first call.
If I change the getHTTPObject function to this...
function getHTTPObject()
{
return new ActiveXObject("Microsoft.XMLHTTP");
}
It works the way I would expect. Is this the way it is intended to work or am I just missing something obvious?