开发者

How to create XMLHttpRequest

I just need the clear explanation o开发者_StackOverflowf the below code for creating XMLHttpRequest.

var xhr = false;
if (window.XMLHttpRequest)
{
    xhr = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
}


It tries to create a native XMLHttpRequest object and if that fails (ancient IE versions), it tries to use the XHR ActiveX object.

Note that it would be good to use e.g. jQuery for AJAX - it wraps it nicely, makes your code much more readable and saves you lots of work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜