How to achieve Multi-browser compatibility with XMLHTTP
This article is about how XMLHTTP achieves multi-browser compatibility. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The code is as follows:
Var xmlhttp=null
If (window.XMLHttpRequest) {
Xmlhttp = new XMLHttpRequest ()
}
If (! xmlhttp&&window.ActiveXObject)
{
Try
{
Xmlhttp = new ActiveXObject ("Msxml2.XMLHTTP.5.0")
}
Catch (e)
{
Try
{
Xmlhttp = new ActiveXObject ("Msxml2.XMLHTTP.4.0")
}
Catch (e)
{
Try
{
New ActiveXObject ("Msxml2.XMLHTTP")
}
Catch (e)
{
Try {new ActiveXObject ("Microsoft.XMLHTTP")} catch (e) {}
}
}
}
}
If (! xmlhttp) {alert ("XMLHTTP is not available. About to jump to a non-Ajax page.") ; location= "nonAjax.htm"}
Thank you for reading! This is the end of the article on "how to achieve multi-browser compatibility in XMLHTTP". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!