As Felgall said.
One better way (and there are others, but this works for me) is:
Code:
function createRequestObject() {
return ( XMLHttpRequest != null )
? new XMLHttpRequest( )
: new ActiveXObject("Microsoft.XMLHTTP");
}
Another seemingly popular way:
Code:
function createRequestObject()
{
try {
return new XMLHttpRequest();
} catch ( ignored ) { }
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch ( oops ) {
return null;
}
}