开发者

GMail like try-again behaviour for my website

Disclaimer: I am living at some place where my net connection gets cut off at least ten times a day. I am not sure if my question makes much sense to guys with stable connection.

Question: Suppose that I am checking GMail when the connection gets cut off. Then, if I unknowingly press my Inbox link, instead of a browser specific error page, I just 开发者_Python百科get a warning div displayed at the top of my page like, "Unable to Connect. Please try in ___ seconds / minutes".

How can I replicate this feature in my web app?


This happens because Gmail uses AJAX requests instead of hyperlinks to new pages.
When you make an AJAX request, you can add an error handler that does whatever you want.

It is impossible to add error handling to normal page navigation.


When you press the link to inbox, you start an ajax request (easy to do using jQuery).

It it succeed, then insert the content and change the url. If it fails, give the user an error.

Remeber to use a plugin like jQuery BBQ to make back/forward buttons work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜