duanjue7508 2013-06-26 19:14
浏览 26

在php文件中检索jquery帖子

I have been searching for hours for this and still cant seem to find the solution. I am trying to use jquery to send a javascript variable to a php form

in one file.. index.php I have the following line:

$.post("test.php", { name: "John", time: "2pm" } );

in test.php, I have

$h = $_POST['name'];
print $h;

but nothing is printed. Sorry if this is a repetitive question. What am I doing wrong?

  • 写回答

2条回答 默认 最新

  • dongyue7796 2013-06-26 19:16
    关注

    You aren't doing anything with the data that is being returned by the server, you need to access the callback and use the data that is being printed.

    $.post("test.php", { name: "John", time: "2pm" }, function(data){
        //data is what you send back from the server, in this scenario, the $h variable.
        alert(data); 
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义