zoukankan      html  css  js  c++  java
  • js ajax请求

    /* 创建 XMLHttpRequest 对象 */
            var xmlHttp;
            function GetXmlHttpObject() {
                if (window.XMLHttpRequest) {
                    // code for IE7+, Firefox, Chrome, Opera, Safari 
                    xmlhttp = new XMLHttpRequest();
                } else {// code for IE6, IE5 
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                return xmlhttp;
            }
            // -----------ajax方法-----------// 
            function checkValidCode() {
                xmlHttp = GetXmlHttpObject();
                if (xmlHttp == null) {
                    alert('您的浏览器不支持AJAX!');
                    return;
                }
                var errorInfo = document.getElementById("errorShow");
                //当用户输入新的验证码内容时影藏用户名错误的提示
                errorInfo.hidden = true;
                var id = document.getElementById('checkCode').value;
                var url = "/checkValidCode/Index?id=" + id + "&t/" + Math.random();
                alert(id);
                xmlHttp.open("POST", url, true);
                xmlHttp.onreadystatechange = getOkGet;//发送事件后,收到信息了调用函数 
                xmlHttp.send();
            }
            function getOkGet() {
                if (xmlHttp.readyState == 1 || xmlHttp.readyState == 2 || xmlHttp.readyState == 3) {
                    // 本地提示:加载中 
                }
                if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
                    var d = xmlHttp.responseText;
                    if(d!="true")
                    {
                        var errorInfo = document.getElementById("errorShow");
                        var validError = document.getElementById("validCodeError");
                        var loginBtn = document.getElementById("loginBtn");
                        var pwdError = document.getElementById("error");
                        validError.hidden = false;
                        errorInfo.hidden = false;
                        pwdError.hidden = true;
                        loginBtn.disabled = false;
                    }
                }
            }
  • 相关阅读:
    mongodb.conf配置文件
    mongodb创建普通角色和普通用户
    add unique index 注意事项
    error: src refspec master does not match any
    innodb_data_file_path配置变更引发mysql重启失败
    time_zone参数配置
    主键有无检测
    gdb在线修改mysql变量
    mybatis连接数据库
    mongo登录
  • 原文地址:https://www.cnblogs.com/ives/p/6831300.html
Copyright © 2011-2022 走看看