Oct 29, 2010
I have a ajax function implementation: when the user is on one site, the ajax call keeps checking the server every 5 seconds if there is a server url change. If there is, there will be a message displayed to direct the user to go to another site.
View 3 Replies
when the user go to another site, the ajax keeps checking every 10 seconds, if there is condition met, the message will be displayed to direct user to go back to the previous site. Also, after the message is displayed, ajax call keeps checking if there is another condition met, if there is, the message will automatically disappear.
The use case is: when one server is down, the message will direct the user to another site. On another site, when the previous server is up, the user could be redirected to the previous site. there is also scenario that when the message is displayed (when server is down), the user may not follow the link to do anything. he/she may simply leave the message on and go to lunch or something, when he/she comes back, the server may be already up and the message should be disappeared instead of keeping showing the message. Therefore, the message should be displayed or disappeared automatically based on the ajax call condition.
I implemented the ajax function and it did check and displayed message. However, it wont' display the message only until the user login or the user does a "refresh" to the page. After the message is displayed, when another condition met, the message won't disappear until the page is refreshed. Then the ajax calls keep doing fine every 10 seconds. The ajax call seems fine since when I set a alert, I did see the popup message show up every 10 seconds (but only after I refreshed the page.)
Now the problem is: the message can't be automatically displayed or disappeared. It can only happen when there is new page load (refresh). How can I solve this problem. I'm thinking of putting "windows.location.reload;" to load the page right after the condition met. But kind of feel I don't need to do this.