• ajax的应用


    ajax的创建 ajax.js

    //创建ajax对象
    function c_xmlhttp(){
      var xmlhttp=null;
    
       if(window.XMLHttpRequest){
           
               xmlhttp= new XMLHttpRequest;  
            //如果请求的不是xml 则将它转为xml
               if(xmlhttp.overrideMime Type){
                    xmlhttp.overrideMime Type("text/html")
                   }
       }
      else if(window.ActiveXObiect){
    
              try{
                  
                   xmlhttp=new ActiveXobject(Wsxml2.XMLHTTP);
            }catch(e){
    
                    try{
                               
                      xmlhttp=new ActiveXObject(Microsoft.XNLHTTP);  
                     }catch(e){}
                }
      }
    return xmlhttp;
    }
    xmlhttp=c_xmlhttp();
    
    function getdata(id){
    
          xmlhttp.open('GET','index.php?id='+id,true);
          xmlhttp.onreadystatechange=handle;
          xmlhttp.send();
    }
    
    function handle(){
         if(xmlhttp.readystate==4){
               if(xmlhttp.status==200){
                        var text=xmlhttp.responseText;
                        document.getElementById('content').innerHTML=text;
                 }
    
        }
    
    }

    inddex.html

    <html>
          <head>
                    <title>测试ajax</title>
    <script  type="text/javascript" src="ajax.js"></script>
           </head>
     <body>
       名称:   <input type="text" name='name' value="" onclick="getdate(this.value)">
     <div id="content"></div>
     </body>
    </html>

    index.php

    <?php
    
    if(isset($_GET['id'])){
     $id=$_GET['id'];
    $mysqli=new mysqli('loclhost','root','my123','myuser') or die("链接失败!");
    $query=$mysqli->query("select *from user where name=".$id);
      if(is_array(mysqli_fetch_row($query))){
            echo "该用户已存在";
      }else
              echo "可以使用";
    }
    
    ?>
  • 相关阅读:
    合约广告系统-在线分配问题
    合约广告系统-合约广告系统
    合约广告系统-常用广告系统开源工具
    knnsearch
    ISOMAP和MDS降维
    dijstra算法
    矩阵大于某个数置零
    mathtype 公式分节隐藏
    fifo 实现问题
    vhdl 数据类型转换 使用IEEE标准库numeric_std 需要进行两次转换 use ieee.numeric_std.all;
  • 原文地址:https://www.cnblogs.com/bugs/p/2765393.html
Copyright © 2020-2023  润新知