dongxing2030 2013-10-17 10:51
浏览 126
已采纳

jquery ajax表单已发送,但var_dump($ _ POST)为空

everyone, i got a very simple problem, but i am really confused... for un hour

in a php page, i have the code:

<script>
$( document ).ready(function() {
  $("#date_avant").click(function(){
    $.post( "_corps_medecin_changedate.php", { name: 'test', id: '1' } );
    $("#consultations_jour").load("_corps_medecin_changedate.php");
  });
});
</script>

And in the page _corps_medecin_changedate.php, just at the beginning, i have the code:

<?php
var_dump($_POST);
$date_debut = $_POST['name'];
?>

And i got msg:

array (size=0)
  empty
Notice: Undefined index: name

I checked the firebug, the parameters are correct in the post list, so i thinked it is sended correctly, but just canot receive in the action page.

Server info :   Apache/2.2.11 (Win32) PHP/5.4.4

And in local envirment.

Can anyone help me?

  • 写回答

3条回答 默认 最新

  • drkug66408 2013-10-17 10:55
    关注

    Your returned data from your $.post call is not automatically made available to your .load() call. They are two separate functions which means your call to load essentially send no POST data to the PHP script.

    You can pass the post parameters as part of your call to load

    <script>
        $( document ).ready(function() {
            $("#date_avant").click(function(){
                $("#consultations_jour").load("_corps_medecin_changedate.php", { name: 'test', id: '1' });
            });
        });
    </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图