Section 2.44. The final test drive


2.44. The final test drive

The customer enters their phone number...

...and then the JavaScript gets their order details and address from the server...

...and fills in the web form.

The customer makes sure the order and address are right, and places the order...

...and 10 minutes later, it's pizza time!

Check it out for yourself!

I think it's time to quit delivering pizzas and start writing Ajax apps. This asynchronous programming stuff is sweet! I bet I could even program an app to make my morning coffee.

60 Second Review

  • For Microsoft browsers, the Ajax request object is ActiveXObject, using either Msxml2.XMLHTTP or Microsoft.XMLHTTP as the type of the object.

  • For non-Microsoft browsers, including FireFox, Safari, and Opera, the Ajax request object is XMLHttpRequest.

  • Static JavaScript is JavaScript that is not in a function, and is run by the browser when it loads your page.

  • You can use static JavaScript to make sure certain pieces of code run before users start working with your web page.

  • A request's ready state indicates what is happening with the request: whether it's being initialized, the server has been contacted, the server is finished, etc.

  • When the ready state of a request is "4", the server has finished processing the request, and any response data is safe to use.

  • Every time a request's ready state changes, the callback function registered with the request is run by the web browser.

  • You need to use the DOM to update the text in HTML display elements like <div> and <span> ; you can use the value property to set the text of form field elements like <input> and <textarea> .

  • Make sure the ordering of your fields works with your application's JavaScript, and not against it, to help avoid confusing your users.

  • You need to use a different request URL for each request to work around caching browsers like Opera and Internet Explorer.





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