简体   繁体   English

如果服务器关闭,则在ajax调用上发生jQuery错误回调

[英]jQuery error callback on ajax call if server is down

I am using jQuery and I am making AJAX request from the many methods available to me. 我正在使用jQuery,我正在从我可用的许多方法中发出AJAX请求。 I am testing error callback condition and so far so good. 我正在测试错误回调条件,到目前为止一直很好。

If I bring the server down then firebug shows the request in RED which means it was an error. 如果我把服务器关闭,那么firebug会以RED显示请求,这意味着它是一个错误。 However error callback is not getting called. 但是没有调用错误回调。 Is this expected ? 这是预期的吗? Or should jQuery's error callback should be invoked when server is disconnected. 或者应该在服务器断开连接时调用jQuery的错误回调。

If the expected behavior is that jQuery's error callback will not be called then how will you notify users that server is down? 如果预期的行为是不会调用jQuery的错误回调那么你将如何通知用户服务器已关闭?

You use the timeout. 你使用超时。 You don't know if the server is down, only if it doesn't respond. 您不知道服务器是否已关闭,只有它没有响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM