zoukankan      html  css  js  c++  java
  • JS中Ajax的实现部分

    2015-9-1

    var url = "<%=servletName%>?user="+username.value+"&pwd="+password.value;
      var xmlHttp = createXMLHttpRequest();                    
      xmlHttp.onreadystatechange = function() {        
      if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {                        
       var message = xmlHttp.responseText; //获取返回文本值                        
       if(isStrEq(message, "succeed")) {
       login.remember(username.value, password.value);
              window.location.href = "/scfz/default.jsp";
       } else {
        $("trTip").style.display = "block";
        $("tip").innerHTML = message;
        username.focus();
       }
      }
     };  
     xmlHttp.open("POST", url, true);
     xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
     xmlHttp.send(null);
           //生成XMLHTTPRequest
            function createXMLHttpRequest() {
     if(window.XMLHttpRequest) {
      return new XMLHttpRequest();
     } else if(window.ActiveXObject) {
      return new ActiveXObject("Microsoft.XMLHTTP");
     }
           }

  • 相关阅读:
    新的开始——3.3
    第一个周末——3.2
    恋爱知识大增——周五3.1
    相安无事——周四2.28
    好几天没写了。。。——周三2.27
    开学第二天——2.26
    开学第一天——2.25
    华为
    微软 Microsoft
    谷歌 google
  • 原文地址:https://www.cnblogs.com/itommy/p/10610428.html
Copyright © 2011-2022 走看看