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

标签 php jquery ajax

我尝试在 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/

相关文章:

jquery - 使用 .next() 和 jQuery 在最后一张和第一张幻灯片之间留出空白

php - 使用SQL进行分页查询

php - 在 MySQLi 准备好的语句中,STMT 代表什么?

选中的 JavaScript 复选框不起作用

javascript - 使用函数为输入添加值

javascript - 找不到jquery,找不到ajax

php - 为什么我不能在我的 PHP 文件中使用 AJAX 发布我的 JSON 数据?

php - 如何判断一个字符串是否是有效的 JSON?

php - jquery中.toggle函数与.load函数结合使用

javascript - 如何使用 javascript 作为客户端调用 MVC Api Controller HttpResponseMessage Post 操作?