【问题标题】:jquery $.post() populates mysql table successfully, but $_POST array is always emptyjquery $.post() 成功填充mysql表,但$_POST数组始终为空
【发布时间】:2013-08-05 14:37:23
【问题描述】:

我有这个过于简化的 jquery post 方法:

  $('#del_prof').click(function() {
  var sss = 12345;
  $.post('logg3.php', { name: sss }); 
  });

和 php:

  $value = ($_POST['name']);
  run_q("INSERT INTO `temp` (info) VALUES ($value)");

问题是:

它成功地填充了 mysql 表,但 $_POST 数组始终为空,无论我尝试回显什么或 var_dump。

这怎么可能?为什么?

【问题讨论】:

  • >所以$_POST不为空
  • 没错,当你var_dumpPOST 数组时,你会得到什么?
  • 这也发生在我身上@A.Wolff - 我在做同样的事情时得到 Array()

标签: php jquery .post


【解决方案1】:

$.post('logg3.php', { name: sss });改为

$.post('logg3.php', { data: { name: sss } });

【讨论】:

  • 这似乎不正确。这是来自 jQuery 文档的示例。 $.post("test.php", { name: "John", time: "2pm" } );。不需要data:
猜你喜欢
  • 2015-07-29
  • 2017-01-07
  • 2010-12-11
  • 2014-01-29
  • 1970-01-01
  • 2016-05-09
  • 2013-04-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多