Section 1.4. Ajax to the rescue


1.4. Ajax to the rescue

Do you see what the problem is? Every time Katie wants to find out the latest number of boards sold, the entire screen is redrawn, and she's left with the Internet version of snow blindness.

Didn't you say that Ajax will let me update the screen without all that reloading? Something about updating just part of the page?

1.4.1. Use Ajax to fix the web report...

Let's change Katie's report to use Ajax to send the request for updated board sales. Then we can get the response from the server, and update the web page using JavaScript and dynamic HTML. No more page reloading, and Katie will be a happy snowboarder again.

Maybe you'll even score a free board...

Work It Through

You're going to need a couple of JavaScript functions to turn Katie's report in to an Ajax-powered app. Below are the names of three JavaScript functions. Draw a line connecting each function name to what you think it will do in the final version of the Boards app.

 getBoardsSold()                         Create a new object for                         talking to the web server. updatePage()                         Ask the server for the latest                         snowboard sales figures. createRequest()                          Set the number of boards sold                         and the cash that Katie's made                         to the most current values. 


Answers on page 63.




Head Rush Ajax
Head Rush Ajax (Head First)
ISBN: 0596102259
EAN: 2147483647
Year: 2004
Pages: 241

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net