learn ajax at amc square learning

9
Learn AJAX at AMC Square Learning

Upload: amc-square

Post on 15-Aug-2015

10 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Learn ajax at amc square learning

Learn AJAX at

AMC Square Learning

Page 2: Learn ajax at amc square learning

What is AJAX ?

• "Asynchronous JavaScript and XML"•New name for an old technique:• JavaScript + DHTML + XMLHttpRequest• In use since at least 1997• I've used it since 2000• Finally someone gave it a name• Already enabled in your Web server and browser

•Use JavaScript asynchronously behind the scenes to load additional data (typically XML) without discarding and reloading the entire Web page.

Page 3: Learn ajax at amc square learning

Why to use AJAX ?

Used for developing fast and dynamic websiteHelps to process performing data in the client side

(JavaScript) with data taken from the server.Selectively modify a part of the page displayed by

the browser without resubmitting.

Page 4: Learn ajax at amc square learning

Elements of AJAX

HTML and CSS JavaScriptThe XMLHttpRequest class

Page 5: Learn ajax at amc square learning

Working of AJAX :Use a programming model with display and eventsUse XMLHttpRequest to get data on the server using two

methods :open() and send()Open() : for creating connectionSend() : for sending request to the serverData processed by the server will be found in the

attributes of XMLHttpRequest object.responseXML : for an XML fileresponseText : for plain textreadyState attribute of XMLHttpRequest is used for finding

the availability of data5 states– 0:not initialized, 1:connection established,

2:request received, 3: ans in progress , 4: finished

Page 6: Learn ajax at amc square learning

Implementing AJAX

•To implement AJAX we need to answer three questions:•What triggers the AJAX request?• Usually a JavaScript event (onblur, onclick, etc.)

•What is the server process that handles the AJAX request and issues the response?• Some kind of URL (use a Service Locator)

•What processes the response from the server(what is the callback method)?• A JavaScript function that gets the response and manipulates the

DOM, based on the text returned.

Page 7: Learn ajax at amc square learning

Security Issues

•Can only hit domain the Web page came from• Cannot access a 3rd party Web Service• However:• You can wrap those requests through your own server• User can allow access to specific sites via browser security settings• IFRAME can access any site (instead of XMLHttpRequest)

Page 8: Learn ajax at amc square learning

Drawbacks of AJAX

Ajax wont work if JavaScript is not activatedBack button may be deactivatedSince data to display are displaying dynamically ,they are not

part of the page. (keywords inside are not used by search engine)

Page 9: Learn ajax at amc square learning

Thank you