我有一个表格,超过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]:http://stackoverflow.com/questions/439463/how-to-get-get-and-post-variables-with-jquery – Nathan 2012-03-29 22:09:18
嗯,我没有最终找到这个问题的解决方案,所以我结束了而不是从我的php文件输出json。 – greatwitenorth 2012-03-30 15:24:06