admin管理员组文章数量:1323323
So I've finally gotten around to trying AJAX again (rather than hidden iframes), and I now remember why I hated AJAX so much in the first place.
It's a simple script that queries the server for the number of private messages the user has received. The server responds with a single number, and the script updates the indicator and sets a timeout for five seconds to query again.
On rare occasion (usually when I go AFK for a while), I start getting the most bizarre HTTP status codes.
On Chrome: "AJAX request failed to retrieve /ajax/network.php, HTTP status 0"
On IE: "AJAX request failed to retrieve /ajax/network.php, HTTP status 12029"
Neither of these codes are valid. What's going on here, and how can I stop it from happening?
So I've finally gotten around to trying AJAX again (rather than hidden iframes), and I now remember why I hated AJAX so much in the first place.
It's a simple script that queries the server for the number of private messages the user has received. The server responds with a single number, and the script updates the indicator and sets a timeout for five seconds to query again.
On rare occasion (usually when I go AFK for a while), I start getting the most bizarre HTTP status codes.
On Chrome: "AJAX request failed to retrieve /ajax/network.php, HTTP status 0"
On IE: "AJAX request failed to retrieve /ajax/network.php, HTTP status 12029"
Neither of these codes are valid. What's going on here, and how can I stop it from happening?
Share asked Sep 28, 2011 at 23:33 Niet the Dark AbsolNiet the Dark Absol 325k85 gold badges474 silver badges599 bronze badges 1- Are these errors repeatable, or do they happen pletely at random? – Alex Commented Sep 28, 2011 at 23:37
1 Answer
Reset to default 6That is an annoying aspect of AJAX. I find it's best to simply treat all non-200 statuses as an error. Really, you're not going to show your users any specific error messages relating to the actual result ("A problem has occurred"), so I'd simply not worry overly about inconsistent error conditions.
jQuery normalizes some of the AJAX behavior, so you may also want to look into using that.
By the way, error 0 in Chrome and 12029 in IE indicate connection problems; since that has nothing to do with HTTP, that's why invalid codes are shown.
本文标签: javascriptAJAX returns unusual status codesStack Overflow
版权声明:本文标题:javascript - AJAX returns unusual status codes - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742142581a2422647.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论