繁体   English   中英

将数据从 javascript 发送到 php 不起作用:结果 null

[英]Sending data from javascript to php isn't working: Result null

所以我的 javascript 文件看起来像这样:

$(document).ready(function() {
     var map = { 
          url: window.location.pathname //get URL without domain
     };
     $.post("/php/SongOutput.php", {map}).done(function(data){
          console.log(map); //Check that the map is correct
          console.log(data); //Show the value of $_POST["url"];
     })
});

php 的位如下:

echo $_POST["url"];

现在,正如您所看到的,我正在尝试将站点的当前 url 发送到 php。 但是我从 console.log(data) 得到的唯一 output; 是 null。 我怎样才能解决这个问题?

$.post("/php/SongOutput.php", map).done(function(data){
      console.log(map); //Check that the map is correct
      console.log(data); //Show the value of $_POST["url"];
 })

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM