• λ我爱Aspx >> C#.Net >> 创建不了XMLHTTP控件 _ASP.NET技巧
  • 创建不了XMLHTTP控件 _ASP.NET技巧

  • :aspxer  Դ:internet  :2007-4-28 23:47:04  ؼ:.net,asp.net,asp,xml
  • 最近在用Ajax开发服务器程序,发现IE浏览器不支持xmlhttprequest对象,而且找不到Microsoft.XMLHTTP控件。

    问题出现了我们需要解决,解决方案如下:

    1、运行下regsvr32 msxml3.dll;

    2、用现成的框架来做ajax;

    3、代码优化:

    if(window.ActiveXObject)

    {

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

    }

    else if(window.XMLHttpRequest)

    {

    xmlHttp = new XMLHttpRequest();

    }

    if(handle_s == null)

    handle_s = "bin/normal.py/db";

    this.xmlHttp.onreadystatechange = handle_l;

    this.xmlHttp.open("GET",handle_s,true);

    this.xmlHttp.send(null);

    或判断浏览器

    var agt = navigator.userAgent.toLowerCase();

    var is_ie = (agt.indexOf("msie") != -1);

    var is_ie5 = (agt.indexOf("msie 5") != -1);

    var is_opera = (agt.indexOf("opera") != -1);

    var is_mac = (agt.indexOf("mac") != -1);

    var is_gecko = (agt.indexOf("gecko") != -1);

    var is_safari = (agt.indexOf("safari") != -1);

    function CreateXmlHttpReq(handler) {

    var xmlhttp = null;

    if (is_ie) {

    // Guaranteed to be ie5 or ie6

    var control = (is_ie5) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP";

    try {

    xmlhttp = new ActiveXObject(control);

    xmlhttp.onreadystatechange = handler;

    } catch (ex) {

    // TODO: better help message

    alert("You need to enable active scripting and activeX controls");

    }

    } else {

    // Mozilla

    xmlhttp = new XMLHttpRequest();

    xmlhttp.onload = handler;

    Ҷƪл˵?
  • һƪAJAX之xmlHttp_Ajax
    һƪxmlHTTP xmlDOC 与 C#中DataSet的结合 实现AJAX简单示例_Ajax