【发布时间】:2012-10-01 20:24:32
【问题描述】:
jQuery AJAX 请求如何同时发送 GET 和 POST 参数?
我正在尝试将do=ajax&id=" + ID 添加到url,但结果请求仅打磨到sss.php,没有查询字符串(获取部分)。谢谢。
$.ajax({
url: "sss.php?do=ajax&id=" + ID ,
type: "post",
data: "ddd=sss",
// callback handler that will be called on success
success: function(response, textStatus, jqXHR){
// log a message to the console
console.log("Hooray, it worked!");
},
// callback handler that will be called on error
error: function(jqXHR, textStatus, errorThrown){
// log the error to the console
console.log(
"The following error occured: "+
textStatus, errorThrown
);
}
});
【问题讨论】:
-
尝试使用
$.post而不是$.ajax -
@defuz:出于所有意图和目的,他/她是使用
post。post只是type: "post"请求的便捷包装器。 -
对我来说,您的解决方案有效。它也应该对你有用。去检查您的 Chrome 网络控制台,看看向服务器发送了什么请求。
-
T.J.克劳德,我明白这一点,但据我所知,我有一个类似的例子可以正常工作,我看到的唯一区别是,我使用了方法
post。也许有一些差异。这只是我的猜测,不是答案。 -
查询字符串与
get不一起post,因为post透明地传递所有内容,AFAIK。