Practical prototype and part 13: The information in this book is distributed on an "as is" basis, without warranty Although every pre-caution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. | 60 CHAPTER 4 AJAX ADVANCED CLIENT SERVER COMMUNICATION Just as Updater builds on Request PeriodicalUpdater builds on Updater. It works like it sounds give it a URL an element to update and a time interval and it will run an at that interval for the life of the page or until you tell it to stop. There are tons of applications for a repeating Ajax request imagine the client side of a chat application asking the server if anyone s spoken in the last 10 seconds. Imagine a feed reader that checks every 20 minutes for new content. Imagine a server doing a resource-intensive task and a client polling every 15 seconds to ask how close the task is to completion. Rather than dispatch an Ajax request as the result of a user action a click of a button or a drag-and-drop these examples set up a request to run automatically thereby saving the user the tedious task of manually reloading the page every time. Let s try it. Reload and run this command in the console new bucket method get insertion bottom frequency 5 Right away we see our first h2 element. Then 5 seconds later we see another. Then another. Now they re reproducing with no help from us. So here s what you ve probably figured out about PeriodicalUpdater It takes the same basic arguments as but it also accepts a frequency parameter in the options object allowing you to set the number of seconds between requests. We could have omitted this parameter and left the frequency at the default 2 seconds but then we wouldn t have had the occasion to talk about it. At the specified interval will create its own instance of passing it the element to update the URL to request and any relevant options. For example the insertion parameter is being passed to which is why new content is being added to the bottom of div bucket instead of replacing the old stuff. OK these h2s are getting on my .