Practical prototype and part 49: 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. | CHAPTER 12 ADVANCED CONTROLS AUTOCOMPLETERS IN-PLACE EDITORS AND SLIDERS 285 Now we ll add the JavaScript that sets up the autocompleter on page load. The syntax for is identical to that of except for the third argument new inputElement updateElement url options Instead of array we provide the URL for the Ajax request. We can give a simple relative URL since and are in the same directory script type text javascript dom loaded function new player_name player_suggestions script Reload the page. Make sure the Firebug console is visible. Click the text box but this time type very slowly. First type a J and then look at the console see Figure 12-5 . l l POST http andrew Book chapterl2 aiitoconiplete 30ms prototypejs line 1222 Figure 12-5. Line indicating an Ajax request went out A line appears in the console to tell us that an Ajax request went out. Look at the details of the request specifically the Post and Response tabs. Now move back to the text field and add an A and then an M. There will be two more logged Ajax calls in the console. You ve probably figured it out is sending out an Ajax request each time the text box s value changes. Seems wasteful doesn t it If the Internet were a series of tubes this is the sort of thing that would clog them up. In fact does some clever throttling it waits for a pause in the input before it sends out a request. To see for yourself clear the text field and then type James at your normal typing speed. Unless you re a hunt-and-peck typist won t make a request until you ve pressed all five keys. Common Options and Features Let s not forget about the fourth argument the one that lets us go under the hood. The two versions of Autocompleter share some configuration options 286 CHAPTER 12 ADVANCED .