today I stuck in the problem with ajax. I'm doing this request:
今天我陷入了ajax的问题。我正在这样做:
$.ajax({
type: 'POST',
url: 'http://hostname/controller/action',
data: {param1 : 'foo'},
timeout: 5000,
success: function(data) {
alert(data);
},
error: function(data) {
console.log(data)
}
});
Script on server side based on Zend. Server - apache2. Response of script is what I expect, but HTTP code is 503 (Service Temporarily Unavailable). If I open this url as get on browser address bar - it returns what I expect(string), but HTTP response code also 503.
基于Zend的服务器端脚本。服务器 - apache2。脚本的响应是我所期望的,但HTTP代码是503(服务暂时不可用)。如果我打开这个URL作为get浏览器地址栏 - 它返回我期望的(字符串),但HTTP响应代码也503。
What may causes it?
可能导致什么呢?
UPD: action contains echo "Some string";
GET or POST - not important. Headers:
UPD:动作包含echo“Some string”; GET或POST - 不重要。头:
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Content-Length:18
Content-Type:application/x-www-form-urlencoded
Host:hostname
Origin:http://hostname
Referer:http://hostname/controller
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36
X-Requested-With:XMLHttpRequest
2 个解决方案
#1
Use complete instead of success and error.
使用完整而不是成功和错误。
$.ajax({
type: 'POST',
url: 'http://hostname/controller/action',
data: {param1 : 'foo'},
complete: function(response) {
if(response['status'] === 200) {
// success
var data = response['responseJSON'];
// ...
} else {
// ...
}
}
});
#2
Problem was on server-side, Zend was modifyied to always return 503. Thanks all for replies
问题是在服务器端,Zend被修改为总是返回503.感谢所有回复
#1
Use complete instead of success and error.
使用完整而不是成功和错误。
$.ajax({
type: 'POST',
url: 'http://hostname/controller/action',
data: {param1 : 'foo'},
complete: function(response) {
if(response['status'] === 200) {
// success
var data = response['responseJSON'];
// ...
} else {
// ...
}
}
});
#2
Problem was on server-side, Zend was modifyied to always return 503. Thanks all for replies
问题是在服务器端,Zend被修改为总是返回503.感谢所有回复