gpt4 book ai didi

PHP/jQuery : jQuery posts variable but PHP not reading it

转载 作者:行者123 更新时间:2023-12-01 08:11:04 24 4
gpt4 key购买 nike

echo "function disp_player (playerID) {";
echo "$.post('editor.php', {'idval': playerID});";

echo "alert(playerID);";
echo "alert(" . $playerlist[$_POST['idval']][0] . ");";

我正在编写一个 PHP 脚本,该脚本应该根据下拉列表中的选择来更改文本。

可以在此处查看该页面 - http://superonlinehockey.com/editor.php

第一个警报起作用并输出玩家ID。将 $playerlist[$_POST['idval']][0] 设置为静态值(例如 $playerlist[770][0])也可以。使用 Firebug,我看到该值已添加到 post 中,并且也使用 Firebug,看起来代码一切正常。但是,当我希望第二个警报与第一个警报相同时,它给了我“未定义”。

有人可以帮助我吗?我发帖有错吗?我是 jQuery 新手,所以我不确定它是如何工作的,但根据我所知道的,我没有发现我的代码有任何问题。

最佳答案

尝试

echo '$.post(\'editor.php\', {\'idval\': playerID});';

这是因为在 php 中 " $some 将充当变量

echo "alert('" . $playerlist[$_POST['idval']][0] . "');";

Codepad

关于PHP/jQuery : jQuery posts variable but PHP not reading it,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13619042/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com