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>
    

      

  • 相关阅读:
    镜像的上传和下载
    ps 命令
    过滤不合格数据
    云计算5-3-2法则
    Python Django初入门
    python web框架
    BootStrap、EasyUI、JQueryUI
    JS正则
    ngonx FastCGI 相关参数调优
    Windows10远程连接错误-出现身份验证错误
  • 原文地址:https://www.cnblogs.com/flw0322/p/10995406.html
Copyright © 2011-2022 走看看