zoukankan      html  css  js  c++  java
  • AJAX基本应用

    if (!window.XMLHttpRequest) {
       window.XMLHttpRequest=function (){
        var http_request;
      try {
       http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
       try {
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (e) {}
      }
        return http_request;
       }
    }

    function loadAjaxPage(url,sParams,sMethod) {
     sMethod=sMethod.toUpperCase();
     var loading_msg='检测中...请稍等!';
     var loader=new XMLHttpRequest;
     if (sMethod=='GET')
     {
      urls=url.split("?");
      if (urls[1]=='' || typeof urls[1]=='undefined')
      {
       url=urls[0]+"?"+sParams;
      }
      else
      {
       url=urls[0]+"?"+urls[1]+"&"+sParams;
      } 
      
      sParams=null;
     }
     if (sMethod=='GET')
     {
         url += "&ajaxtime=" + Math.random();
     }
     else if(sMethod=="POST")
     {
         url += "?ajaxtime=" + Math.random();
     } 
     loader.open(sMethod,url,true);
     if (sMethod=="POST")
     {
      loader.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
     }
     loader.onreadystatechange=function(){
    //  if (loader.readyState==1)
    //  {
    //      document.getElementById("btnchk").disabled = 'disabled';
    //   oContainer.innerHTML=loading_msg;
    //  }
      if (loader.readyState==4)
      {
          // oContainer.innerHTML = "";
       eval(loader.responseText);
       //document.getElementById("btnchk").disabled = '';
      }
     }
     loader.send(sParams);
    }

    car =
    {
        chk : function(aa,bb)
        {
       
            $("divchk").innerHTML = '检测中...请稍等!';
            loadAjaxPage("Default6.aspx","aa="+aa+"&bb="+bb,"POST");
       
        }
    }

  • 相关阅读:
    HDU 4405 Aeroplane chess (概率dp)
    条件编译符号与公布
    hdu 1722 Cake 数学yy
    电脑显示U盘,可是读取不了
    多本Web前端深度修炼书籍(提供网盘下载链接)
    HDU 5410(2015多校10)-CRB and His Birthday(全然背包)
    Servlet体验之旅(二)——Session、Cookie
    <pre>标签
    每天学点Python之comprehensions
    编写html经常使用而又easy忘记的语句
  • 原文地址:https://www.cnblogs.com/lgf8612/p/1865741.html
Copyright © 2011-2022 走看看