"dirtside" <> wrote in message
news: oups.com...
> That looks like IE-specific code... whatever I do has to be
> cross-platform. (I tried the above code in Mozilla, and was unsurprised
> when the JavaScript debugger said it didn't know what 'ActiveXObject'
> was
).
>
Try this.
function getRequestObj() {
var ret = null;
var xml = [
"MSXML2.XMLHTTP.5.0",
"MSXML2.XMLHTTP.4.0",
"MSXML2.XMLHTTP.3.0",
"MSXML2.XMLHTTP",
"Microsoft.XMLHTTP"];
if (window.ActiveXObject) {
for (var i=0; i<xml.length; i++) {
try {
ret = new ActiveXObject(xml[i]);
break;
} catch(e) {}
}
} else if(window.XMLHttpRequest) {
try {
ret = new XMLHttpRequest();
} catch(e) {}
}
return ret;
}
var sURL = "http://some.server.com/some_filename.gif";
var oXML = getRequestObj();
oXML.open("GET",sURL,false);
oXML.send();
// if you want the "GIF89" content prefix
alert(oXML.responseText);
// if you want the binary data stream
alert(oXML.responseBody);