Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Practical prototype and scipt.aculo.us part 15: 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. | 72 CHAPTER 4 AJAX ADVANCED CLIENT SERVER COMMUNICATION Figure 4-17. Slightly less ugly We re almost there. The last part is the easiest because it s built into Ajax.Updater. Instead of designating one container to update you can designate two one for successful requests and one for unsuccessful requests. The conventions followed by HTTP status codes make it easy to figure out what s an error and what s not. new Ajax.Updater success breakfast_history failure error_log breakfast.php insertion top parameters food_type waffles CHAPTER 4 AJAX ADVANCED CLIENT SERVER COMMUNICATION 73 Victory As Figure 4-18 shows bad requests show up bright red in the error log. Figure 4-18. Errors now look like errors. Now put that taste parameter back into the statement and watch your valid request appear in a pleasing green color as shown in Figure 4-19. new Ajax.Updater success breakfast_history failure error_log breakfast.php insertion top parameters food_type waffles taste delicious 74 CHAPTER 4 AJAX ADVANCED CLIENT SERVER COMMUNICATION Figure 4-19. Valid entries now look valid. Example 2 Fantasy Football It s time to talk about the site we ll be building together over the course of this book. JavaScript has a place on many different kinds of sites but web applications are especially ripe for applying the topics we ll cover in the pages ahead. So let s build a site that people need to use rather than just read. We ll build the sort of site that Ajax can have the greatest impact on. The App For the next few chapters we ll be building a fantasy football site. For those who don t know apologies to my non-American readers fantasy football is a popular activity among followers of professional American football. Here s fantasy football in a nutshell