創建XMLHttpRequest對象:

<script language="Javascript" type="text/Javascript">

var request = false;

try {

request = new XMLHttpRequest();

} catch (trymicrosoft) {

try {

request = new ActiveXObject("Msxml2.XMLHTTP");

} catch (othermicrosoft) {

try {

request = new ActiveXObject("Microsoft.XMLHTTP");

} catch (failed) {

request = false;

}

}

}


if (!request)

alert("Error initializing XMLHttpRequest!");

script>