【发布时间】:2012-04-13 14:57:02
【问题描述】:
我有一个通过 ajax 发布数据的表单。响应以 URL 中的 GET 变量的形式返回。例如,如果表单数据写入失败,则返回地址为:http://example.com/?error=1
我将如何使用 jquery 进行检查。现在,当我对 msg 变量执行 console.log 时,我只会得到 example.com 的 html 输出(我想这是有道理的)。我需要 GET 变量。我将如何实现这一目标?
$('#wp_email_capture').submit(function(e){
var email = $('#wp-email-capture-email').val();
$.ajax({
type: "GET",
url: "/",
data: "wp_capture_action=1&wp-email-capture-email=" + email
}).done(function( msg ) {
console.log(msg)
});
e.preventDefault();
});
【问题讨论】:
-
查看这篇文章:[如何使用 JQuery 获取 GET 和 POST 变量?][1] [1]:stackoverflow.com/questions/439463/…
-
好吧,我最终没有找到解决这个问题的方法,所以我最终从我的 php 文件中输出了 json。
标签: javascript jquery ajax post get