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");
     }
           }

  • 相关阅读:
    [面试题]什么是面向对象编程
    面向对象编程的新手理解
    Object of type type is not JSON serializable
    STL---map
    STL---llist
    Div标签使用inline-block有间距
    STL---vector
    KMP算法
    算法06
    算法05
  • 原文地址:https://www.cnblogs.com/itommy/p/10610428.html
Copyright © 2011-2022 走看看