XmlHttpRequest是一个用于在网页中读取服务器数据的组件。最初是由微软开发用来访问Outlook Web Access 2000的。在目前流行的IE版本中都支持(从IE5到IE9),只不过问题是这个东东目前还没有成为标准(W3C正在讨论,只有一个draft可作参考),于是就有了万恶的浏览器兼容性的问题。常见的生成XmlHttpRequest对象的Javascript是这么写的:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function NewXmlHttpRequest() {
    try{
        return new window.XMLHttpRequest();
    }
    catch(e) {} //standard API
    try{
        return new ActiveXObject("Msxml2.Xmlhttp.6.0");
    }
    catch(e) {}
    try{
        return new ActiveXObject("Msxml2.Xmlhttp");
    } catch(e) {}
    //try other browser API
    throw new Error("XmlHttpRequest is not supported.");
}

在IE7之前,IE中的XmlHttpRequest组件都是由Msxml提供的。尽管Msxml目前有很多版本(从3.0到6.0都是被支持的),但只有3.0是从Win2000到Vista都带的,6.0只在XP SP3和Vista以之后的操作系统中有,而且3.0有个好处是创建的时候只要写”Msxml.Xmlhttp”即可,不用像6.0一样加上后缀的版本号。当然6.0在安全和性能方面都要比3.0好,大有取而代之的趋势。

您还可能感兴趣的日志:

  1. XmlHttpRequest学习笔记 (4) 解析Xml时的安全性
  2. XmlHttpRequest学习笔记 (2) 基本操作
  3. XmlHttpRequest学习笔记 (3) 解析Xml
  4. XmlHttpRequest学习笔记 (7) 异步模式
  5. XmlHttpRequest学习笔记 (5) HTTP报头
  6. XmlHttpRequest学习笔记 (6) 查看HTTP状态
  7. HTTP状态12007

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
© 2004 - 2011 Leona+Suffusion theme by Sayontan Sinha