I am trying to implement decent navigation in an AJAX application. Now I am doing the following:
- Each time a user clicks on an AJAX link, a corresponding call is made and the hash is changed.
- Whenever a new page loads, I check to see if a hash is present and make an appropriate AJAX call to refresh the page. This ensures that bookmarks will work as expected.
- Every 500 ms, I check if the hash has changed, and make the appropriate AJAX call. This ensures that users press the back / forward buttons, albeit with a delay in merging.
The third point is a bit annoying: I would prefer not to have a timeout every 500 ms to check the hash, since most of the time it will remain the same.
Is there a better way to handle this? I can’t come up with any alternatives, but maybe something is missing.
Please do not point me to ready-made solutions if you do not know that they are based on a different mechanism.
source
share