qq_39196807 2022-06-10 20:57 采纳率: 83%
浏览 68
已结题

php处理Ajax,post提交JSON.stringify的数据?

php输出的数据
var_dump($_POST);

array(16) { ["title"]=> string(35) "你好吗" ["company"]=> string(6) "你好" ["headmaster"]=> string(1) "3" ["Dheadmaster"]=> string(1) "3" ["years"]=> string(4) "2022" ["classroomtype"]=> string(1) "5" ["kzcd"]=> string(3) "127" ["select"]=> string(14) "30,31,32,33,34" ["rank"]=> string(0) "" ["stime"]=> string(0) "" ["etime"]=> string(0) "" ["scorestime"]=> string(0) "" ["scoreetime"]=> string(0) "" ["tabletimesel"]=> string(0) "" ["filestime"]=> string(0) "" ["fileetime"]=> string(0) "" }

JS

 var d = {};
      var t = $('form').serializeArray();
      var data = $('form').serialize();

      $.each(t, function() {
        d[this.name] = this.value;
      });
      console.log(JSON.stringify(d));
      var qwe = JSON.stringify(d);

      $.ajax({
           dataType: "json",
           url: 'classroomupdate.php?t=update&cd=<?php echo $_GET['id']?>',
           type:'post', 
           data:qwe, 


{"title":"你好吗","company":"你好","headmaster":"3","Dheadmaster":"3","years":"2022","classroomtype":"5","kzcd":"127","select":"30,31,32,33,34","rank":"","stime":"","etime":"","scorestime":"","scoreetime":"","tabletimesel":"","filestime":"","fileetime":""}

PHP 怎样获取键对应的值?

  • 写回答

1条回答 默认 最新

  • 今夕何夕2112 2022-06-11 18:45
    关注
    <?php
    //$_POST 是一个数组
    $title = $_POST['title'];
    $company =  $_POST['company'];
    // ... ...是这个意思吗?
    echo "title is $title; company is $company";
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 6月30日
  • 已采纳回答 6月22日
  • 创建了问题 6月10日

悬赏问题

  • ¥30 软件自定义无线电该怎样使用
  • ¥15 R语言mediation包做中介分析,直接效应和间接效应都很小,为什么?
  • ¥15 Jenkins+k8s部署slave节点offline
  • ¥15 微信小游戏反编译后,出现找不到分包的情况
  • ¥15 如何实现从tello无人机上获取实时传输的视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)