AJAX - The Complete Reference

(avery) #1

PART II


Chapter 9: Site and Application Architecture with Ajax 471


The user thinking that they would like to see the pretty image once again clicks forward
in their browser rather than selecting the link. The library then sees the new hash value, and
it sees that there is a saved value. However, it was added to the history manually as if you
recall, we did not make an XHR request here. Therefore, there is no data available in the
persistent storage used to re-request things. Instead, the history system’s global callback
function that was specified by the initial call to init() will be called so that it can set things
right. In this case, it is a function called updateState() that looks at the hash value and
tries to rebuild the page, fetching the file list and inserting the <img> tag that points to the
desired thumbnail. However, we need to emphasize that since either we have been here
before or we are entering via a bookmark, we must make sure to avoid re-adding it to the
history again.
Free download pdf