Only IE supports ActiveX objects.
You could use a wrapper function to return an XMLHTTP object:
Code:
function createXMLHttpRequest() {
try { return new XMLHttpRequest(); } catch(e) {}
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
alert("XMLHttpRequest not supported");
return null;
}
var xhReq = createXMLHttpRequest();
Why bother reinventing the wheel though? Let a framework do all the heavy lifting:
Code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
function request (page, objDiv){
var timestamp = new Date().getTime();
$(objDiv).html('<img src="images/blu.gif" width="16" height="16" id="loading" align="center"><br><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Performing Specified Action...</font>');
$.get(page, {'time' : timestamp}, function(response){
$(objDiv).html(response);
});
}
</script>