Php Firebug AJAX请求中止-无响应正文或标题(同一域)
我试图用Php Firebug AJAX请求中止-无响应正文或标题(同一域),php,javascript,jquery,ajax,Php,Javascript,Jquery,Ajax,我试图用数据类型:“json”发出一个AJAX请求,我是Firebug,它一直将请求显示为“已中止” 以下是代码片段: var postData = "someVar=someValue&otherVar=otherValue", msg; $.ajax({ type: "POST", url: "/path/to/page", data: postData, dataType: "json", cache: false, success:
数据类型:“json”
发出一个AJAX请求,我是Firebug,它一直将请求显示为“已中止”
以下是代码片段:
var postData = "someVar=someValue&otherVar=otherValue", msg;
$.ajax({
type: "POST",
url: "/path/to/page",
data: postData,
dataType: "json",
cache: false,
success: function(response) {
if (typeof response.row != undefined) {
$('#my-select')
.append($('<option></option>')
.attr("value", response.row.id)
.text(response.row.name)
);
msg = response.msg;
} else {
msg = 'failed';
}
alert(msg);
},
error: function(xhr, status, thrown) {
// EDIT 1
alert(status); // <-- It's alerting "timeout"
}
});
Apache错误日志中没有显示任何内容。我在浏览器中手动导航到该页面,没有出现任何错误(只有一个白色屏幕和一些文本)
注意:这适用于我的本地主机,但不适用于测试服务器。
编辑:添加了
错误()
回调,并发出“超时”警报。请求可能已超时。
首先尝试将默认超时值增加到稍高的值,如下所示:
$.ajax({
type: "POST",
url: "/path/to/page",
data: postData,
timeout: 3000,
dataType: "json",
[...]
默认超时值显然取决于浏览器,因此它可能低于脚本执行时间,或者由其他设置,等等
我最近有这个。。绞尽脑汁记住问题和解决办法。你没有击中IIS框,是吗?@MattH不,它在Linux Apache服务器上。可能还存在SSL证书问题。不过,我最终还是用篡改数据而不是Firebug找到了它。。。。至少这是我上次遇到ajax问题时使用的。好的,现在我会安装它,谢谢。还有其他想法吗?在今天之前,它是有效的,我之前没有设置
数据类型:“json”
(例如,之前的纯文本/html响应)。有什么问题吗?嗯。。。我没有将数据类型:“json”
与$.ajax
一起使用,而是使用$.getJSON
。如果您试图从另一个域获取ajax
,我只会怀疑这有问题。
Host mydomain.com
User-Agent Firefox/8.0.1
Accept application/json, text/javascript, */*; q=0.01
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
DNT 1
Connection keep-alive
Content-Type application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With XMLHttpRequest
Referer http://mydomain.com/path/to/page
Content-Length 125
Cookie PHPSESSID=somerandomstring
$.ajax({
type: "POST",
url: "/path/to/page",
data: postData,
timeout: 3000,
dataType: "json",
[...]