zoukankan      html  css  js  c++  java
  • 学习进度_第十二周

    编码时间:课上2h+课下4h

    博客:0

    学习的知识:

     ajax实现php异步交换数据,但是掌握不是很熟练

    php代码

    <?php
    
     
    
      header('Content-Type: application/json');
    
      header('Content-Type: text/html;charset=utf-8');
    
     
    
      $email = $_GET['email'];
    
     
    
      $user = [];
    
     
    
      $conn = @mysql_connect("localhost","Test","123456") or die("Failed in connecting database");
    
      mysql_select_db("Test",$conn);
    
      mysql_query("set names 'UTF-8'");
    
      $query = "select * from UserInformation where email = '".$email."'";
    
      $result = mysql_query($query);
    
      if (null == ($row = mysql_fetch_array($result))) {
    
        echo $_GET['callback']."(no such user)";
    
      } else {
    
        $user['email'] = $email;
    
        $user['nickname'] = $row['nickname'];
    
        $user['portrait'] = $row['portrait'];
    
        echo $_GET['callback']."(".json_encode($user).")";
    
      }
    
     
    
    ?>
    

      js代码

    <script>
    
        $.ajax({
    
          url: "http://test.localhost/UserInterfaceForChatroom/UserInformation.php?email=pshuyue@gmail.com",
    
          type: "GET",
    
          dataType: 'jsonp',
    
          //      crossDomain: true,
    
          success: function (result) {
    
            //        data = $.parseJSON(result);
    
            //        alert(data.nickname);
    
            alert(result.nickname);
    
          }
    
        });
    
      </script>
    

      

  • 相关阅读:
    一、用Delphi10.3模拟读取百度网页,并读取相关头部信息
    计算机语言发展史
    VMware workstation 14 安装 iOS虚拟机
    mysql-1
    linux网页资料链接
    Ubuntu常用命令大全
    搭建yum源
    CentOS7安装iptables防火墙
    nginx 第二课
    交换机
  • 原文地址:https://www.cnblogs.com/flw0322/p/10995406.html
Copyright © 2011-2022 走看看