douhu8851 2016-08-01 15:19
浏览 52

来自Ajax的值显示在控制台中,但它不是作为Php值工作

i've got a little question regarding the usage of Ajax. I've done a search for the same issues but i can't find something to look alike with my problem.

Here is my code.

$(document).ready(function()
{
$("#nume").blur(function() { 

numeform = $("#nume").val(); 

if (numeform){  
    $.ajax({
    type: "POST",
     url: "../../index.php",
         data: {numeform : numeform}, 
         cache: false,
        success: function(response) {
            data = numeform;
            console.log(data);                           
        } 
      });
    }
});
});

and in the php file i have

$data = $_POST['data'];
echo $data; 

The console shows as it should. Any help is greatly appreciated.

  • 写回答

1条回答 默认 最新

  • douhongxie5436 2016-08-01 15:25
    关注

    The console is logging the variable you are sending not what you're receiving, that is why it looks correct. If you log response then you'd see a problem.

    For the PHP part you're reading $_POST['data'] when you should be reading $_POST['numeform'] becuse that is what you sent in your ajax request

    {numeform : numeform}

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作