gpt4 book ai didi

php - $_REQUEST 有效,但 $_POST 无效 -

转载 作者:行者123 更新时间:2023-12-01 02:19:59 26 4
gpt4 key购买 nike

感谢您分享我的头痛 - 这是简短的说明:

最近继承了一个编码很差的 WordPress 网站 - 该网站利用了 WP Contact Form 7 -

我剥离了所有 WP-CF 代码(因为 WordPress 在移交给我之前就已经被剥离了)——只是为了制作一个简单的补丁脚本并继续实际工作。

我用这个脚本替换了 WPCF 脚本:(让事情对我来说尽可能简单):

jQuery(document).ready(function() {
$ = jQuery;
console.log("Ready");
$("#quack-button").click(function(e) {
console.log("Quack");
e.preventDefault();
e.stopPropagation();
POSTDATA = $.param($("#quack-form").serializeArray());
$.ajax({
method : "POST",
url : "http://www.domain.com/contact.php",
data : POSTDATA,
success : function(response) {
console.log(response);
alert("Thank you ! We'll get in touch as soon as we can -! ");
}
});
});
});

但是,在尝试了 $.paramserialize 的许多不同形式/组合之后 -服务器端脚本继续返回一个空白数组....

print_r($_POST);

但是,当我将其更改为 print_r($_REQUEST) 时 - 一切正常,很好......

现在,这可能会以什么方式发生?我错过了哪些盲点可能会造成这种情况......?

这是我一段时间以来遇到的最令人困惑的事情...我很感激任何人对此的理解...

最佳答案

如果您想将其作为 $_POST 发送,请更改此行:

method: 'POST'

对此:

type: 'POST'

根据docs ,就是这样设置的。

type (default: 'GET')
Type: String
The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.

关于php - $_REQUEST 有效,但 $_POST 无效 -,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25634817/

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