首页 > 解决方案 > 从ajax发送数据到php返回NULL

问题描述

我试图将数据从 ajax 发送到 php。

当我试图提醒它时,它工作得很好,但是当我试图发布数据时它没有工作。

我的阿贾克斯

function onBtnClick(event){
    var nah = JSON.stringify(points);
    alert(nah);
    $.ajax( {
      url:"../php/points.php",
      type:'post',
      data: {point:nah},
      success: function(response){
          window.location = "../php/points.php";
      }

  })

  }

我试图发布的观点

 points[currentid] = {id: currentid, x: event.offsetX, y: event.offsetY};
  currentid++;

php代码

if(isset($_POST['point'])){
        $user = $_POST['point'];

        $decoded = json_decode($user, true);

        var_dump($decoded);

        echo $decoded;
    }

标签: javascriptphpajax

解决方案


推荐阅读