zoukankan      html  css  js  c++  java
  • 16.PHP_Ajax模拟服务器登录验证

    Ajax模拟登陆验证

    index.php

    <script language="javascript">
        var http_request = false;

        function createRequest(url){
            http_request = false;
            if(window.XMLHttpRequest){                   //Mozilla、Safari等浏览器
                http_request = new XMLHttpRequest();
            }else if(window.ActiveXObject){              //IE
                try{
                    http_request = new ActiveXObject("Msxml2.XMLHTTP");
                }catch(e){
                    try {
                        http_request = new ActiveXObject("Microsoft.XMLHTTP");
                    }catch(e){}
                }
            }
            if(!http_request){
                alert("不能创建XMLHTTP实例!");
                return false;
            }
            http_request.onreadystatechange alertContents//指定相应方法
            //发出HTTP请求
            http_request.open("GET" ,url ,true);
            http_request.send(null);
        }

        function  alertContents() {
            if (http_request.readyState == 4) {//处理服务器返回的信息
                if (http_request.status == 200) {
                    alert(http_request.responseText);
                else {
                    alert("Ajax验证页面发生错误");
                }
            }
        }
    </script>

    <script language="javascript">
        function checkName(){
            var username = form1.name.value;
            if(username == ""){
                window.alert("name is null!");
                return false;
            }else {
                createRequest('checkname.php?username=' + username + '&nocache=' new Date().getTime());
            }
        }
    </script>

    <form name="form1" method="post" action="">
        <select name="name">
            <option value="xiaoming">xiaoming</option>
            <option value="xiaoli">xiaoli</option>
            <option value="xiaowang">xiaowang</option>
        </select>
        <input type="submit" name="Submit" value="Ajax" οnclick="checkName()">
    </form>



     

    CheckName.php

    <?php
        //模拟服务器验证
        $username $_GET['username'];
        echo 'Ajax Check web Get Name: '.$username;
    ?>

     

  • 相关阅读:
    pytorch bug: for step,data in enumerate(loader)+Connection reset by peer
    pytorch bug
    ImportError: No module named '_tkinter', please install the python3-tk package
    nvidia-docker+cuda8.0+ubuntu16.04
    召回率,精确率,mAP如何计算
    tensorflow 迭代周期长,每个epoch时间变慢
    yolov3中 预测的bbox如何从特征图映射到原图?
    知乎问题:目标检测领域还有什么可以做的?
    目标检测数据增强,旋转方法
    OpenBLAS(1)----安装OpenBLAS
  • 原文地址:https://www.cnblogs.com/csnd/p/12061972.html
Copyright © 2011-2022 走看看