zoukankan      html  css  js  c++  java
  • ajax 异步与同步

    function RequestByGet(nProducttemp,nCountrytemp)
    {
        var xmlhttp

        if (window.XMLHttpRequest) 
        { 
             //isIE   =   false; 
             xmlhttp   =   new   XMLHttpRequest(); 
        } 
        else if (window.ActiveXObject)
        { 
             //isIE   =   true; 
             xmlhttp   =   new   ActiveXObject("Microsoft.XMLHTTP"); 
        }
                    
        //Web page location.
        var URL="http://www.baidu.com/;
        xmlhttp.open("GET",URL, false);
        //xmlhttp.SetRequestHeader("Content-Type","text/html; charset=Shift_JIS")
        xmlhttp.send(null);
        var result = xmlhttp.status;
      
        //OK
        if(result==200)
        {
            document.getElementById("div_RightBarBody").innerHTML=xmlhttp.responseText;
        }
        xmlhttp = null;

    }


    //异步传输模式
    var xmlhttp

    function RequestByGet(nProducttemp,nCountrytemp)
    {

        if (window.XMLHttpRequest) 
        { 
             //isIE   =   false; 
             xmlhttp   =   new   XMLHttpRequest(); 
        } 
        else if (window.ActiveXObject)
        { 
             //isIE   =   true; 
             xmlhttp   =   new   ActiveXObject("Microsoft.XMLHTTP"); 
        }
                    
        //Web page location.
        var URL="http://www.baidu.com/";
        xmlhttp.open("GET",URL, true);
        xmlhttp.onreadystatechange = handleResponse;
        //xmlhttp.SetRequestHeader("Content-Type","text/html; charset=UTF-8")
        xmlhttp.send(null); 

    }

    function handleResponse()
    {

        if(xmlhttp.readyState == 4 && xmlhttp.status==200)
        {
            document.getElementById("div_RightBarBody").innerHTML=xmlhttp.responseText;
            xmlhttp = null;
        }

    }

  • 相关阅读:
    新安装的Apache和php,测试可以解析phpinfo,但是无法打开drupal网站
    Drupal7安装注意事项
    drupal7 为视图添加 过滤标准 内容类型
    Drupal网站报错:PDOException: in lock_may_be_available()
    窗口聚合函数与分组聚合函数的异同
    Linux环境下段错误的产生原因及调试方法小结(转)
    gzip 所使用压缩算法的基本原理(选摘)
    InfluxDB使用纪录
    子网掩码解释(转)
    列存的压缩原理学习
  • 原文地址:https://www.cnblogs.com/czjone/p/1854016.html
Copyright © 2011-2022 走看看