Generation example of XMLHttpRequest object in AJAX in different browsers

Time:2021-9-4
Copy codeThe code is as follows:
<script type=”text/javascript”>
function ajax()
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch (e)
{
Alert (“your browser does not support Ajax!”);
return false;
}
}
}
</script>