• ajax异步操作学习


    创建xhr对象实现浏览器全兼容         

      function createXmlHttp() {//创建xhr对象          

           var xhobj = false;              

       try {               

          xhobj = new ActiveXObject("Msxml2.XMLHTTP"); // ie msxml3.0+      

               } catch (e) {               

          try {                 

            xhobj = new ActiveXObject("Microsoft.XMLHTTP"); //ie msxml2.6           

              }

    catch (e2)

    {           

                  xhobj = false;          

               }            

         }              

       if (!xhobj && typeof XMLHttpRequest != 'undefined')

    {

    // Firefox, Opera 8.0+, Safari            

             xhobj = new XMLHttpRequest();         

            }            

         return xhobj;     

            }

    通过GET方式进行Ajax操作; var xhr;       

      window.onload = function () {             xhr = createXmlHttp();         }         function doAjax() {             xhr.open("GET", "Ajax.aspx?isAjax=1", true);             xhr.onreadystatechange = watching;             xhr.send(null);         }         function watching() {             if (xhr.readyState==4) {                 if (xhr.status == 200) {                     var txt = xhr.responseText;                     document.getElementById("hh").innerHTML = txt;                 }             }             else {                 document.getElementById("hh").innerHTML="服务器出错了"+xhr.status;             }         }

  • 相关阅读:
    python爬取网络上图片【小例子】
    python统计英文单词出现次数【小例子】
    python敏感字处理【小例子】
    platform操作系统信息
    迭代器
    xxxxx
    test
    Jquery
    Jquery二
    DOM文档对象模型
  • 原文地址:https://www.cnblogs.com/msdncrazy/p/3021279.html
Copyright © 2020-2023  润新知