AJAX Introduction by Bhanwar Gupta - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

AJAX Changes How Web Apps are Built
Components & Events

Order Entry
Item List Component
ErrorViewer Item List (DIV) (DIV) Events/Actions
Validation
Shopping Cart (DIV)
Persistence

Shopping Cart Component
Event Handlers Shipping Form (DIV) GUI Creation
Shipping Component
Billing Form (DIV)

Unit of work is a component Three-Tier Client/Server Model Client code has validation, flow, layout, data interchange No submit buttons—save buttons
Only parts of pages are updated at a time

Billing Component
AJAX -- Message Flow
<script type=“text/javascript”>

XMLHttpRequest

function handleResponse() { …read response from server …get a handle to the DIV If Not OK

Replace DIV contents with msg }

Message
name=bhanwar Or
<name>Bhanwar</name>

function checkName( name ) { …initialize request (url, parms) …register callback function …call the server
}

Message
status=999
msg=Not a valid name

Validation Servlet

ValidateName( req, res…) { parse request
lookup name in database is it valid?

if so, return OK otherwise
return error message

Database

 

00005.jpgSave<div id=status>Not a Valid Name
Client/Browser

 

00002.jpgServer