gpt4 book ai didi

jquery - 使用 $.post 发布数据失败并显示空数据

转载 作者:行者123 更新时间:2023-12-01 05:05:51 25 4
gpt4 key购买 nike

我想使用 jQuery 发送一些数据

var uri = "some url";

$.post(uri,
{ message: "test"},
{"format" : "json"},
'html');

return false;

当 php 脚本收到请求时,消息字段为空。为什么?

<小时/>

编辑:我使用 zend 框架读取帖子数据

$this->getRequest ()->getPost ( 'message' );

上面的 js 代码可以在本地主机上运行,​​但在服务器上消息为空。我检查了 isPost(),它说没有帖子。

最佳答案

您正在将两个对象传递给$.post。没有理由这样做。我想你只是想要这个:

$.post(uri,
{ message: "test"},
'html');

服务器将理解发布数据的格式。

关于jquery - 使用 $.post 发布数据失败并显示空数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6030799/

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