gpt4 book ai didi

php - Ajax 是 "Getting"而不是 "Posting"

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

我尝试在 jquery 代码中使用 Post 方法,但由于某种原因它使用 Get 方法。我正在 WordPress 框架下工作,该框架已将“$”函数重命名为 jquery,然后我将其重命名为 $j。谁能帮我完成这个简单的功能?

  $j.ajax({
method: "POST",
url: "extension/marker.php",
data: "series=test",
dataType: "text",
success: function(data){
$j("#text").text(data);
console.log('success' + data);
}
});

PHP 文件:

  <?php 

if($_POST['series'] == "test")
echo 'yay!';

if($_GET['series'] == "test")
echo 'boo!';

?>

最佳答案

方法:“POST” 应为类型:“POST”。请参阅the docs .

type
Default: 'GET'
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 - Ajax 是 "Getting"而不是 "Posting",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2206145/

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