SlideShare uma empresa Scribd logo
1 de 28
Introduction to AJAX
Venkat pinagadi
What is Ajax?
 Asynchronous
 JavaScript
 And

 XmlHttpRequest (XHR)


Some use XML, but to me that’s misleading
Why Ajax?


XHR Support across all browsers




Emergence of broadband





Based on DOM, CSS, XHTML
AJAX-based JavaScript can take considerable
bandwidth to download

The “Killer App” - Google Maps
A Catchy Acronym


Coined by Jesse James Garrett of Adaptive Path
(February 2005)
Why Ajax?
Why Ajax?
AJAX Alternatives


Macromedia Flash


Requires a plug-in





Java Web Start/Applets
.NET – No Touch Deployment




So what? It comes already with almost every browser

Both need a runtime preinstalled

Handheld device browsers generally do not
support the full range of Ajax technologies.
Implementing AJAX


To implement AJAX we need to answer three
questions:


What triggers the AJAX request?




What is the server process that handles the AJAX
request and issues the response?




Usually a JavaScript event (onblur, onclick, etc.)

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.
XmlHttpRequest Object (XHR)





The Heart of AJAX
First implemented in IE in 1997 as part of the
new DHTML standard
Response comes in one of two properties:




responseXML – Returns a DOM document (can use
functions such as, getElementById())
responseText – A text string (can be HTML, or even
JavaScript code)
XHR : Creating
XHR : Sending the Request

true = asynchronous
XHR : Using a callback handler
Handling the Response



Response can be one of the following:


Formatted data (XML, other custom format)
 XMLHttpRequest.responseXML





Decouples the server from presentation issues
Could perform XSLT transformation on returned XML

HTML
 XMLHttpRequest.responseText


Server generates HTML, script “injects” HTML via

innerHTML




Server is now concerned with presentation

JavaScript
 XMLHttpRequest.responseText
 Use the eval() JavaScript command


Again, our server code is concerned with presentation
AJAX Concerns






Security
Browser Compatibility
Accessibility
The Back Button
What if JavaScript is Turned Off?
AJAX and the Back Button






Huge usability issue
Returning to the previous state may not be
possible when a page is updated dynamically
Difficult to bookmark on a particular page state
Really Simple History (RSH) framework
addresses these issues


http://codinginparadise.org/projects/dhtml_history/README.html
AJAX Security – Server of Origin
Policy
AJAX Security


Browsers impose security restrictions


Cannot make requests via the XHR outside of
the domain the web page came from
Can set security on IE to get around this (but you
really don’t want to)
 Mozilla-based browsers require digitally signing
your script (Yuck!)




User must approve going to site.


Firefox requires additional code
AJAX Security


Calling third-party web-services




Application Proxies – Call the web-service
from a servlet
Apache Proxy – Configure Apache to invisibly
reroute from the server to the target web
service domain
Encapsulating our AJAX Logic
Encapsulating our AJAX Logic
(cont.)
Problems with JavaScript


Most Java developers know enough
JavaScript to be dangerous.




If you don’t know what you are doing, you
could cause memory leaks on the client
machine.

Most JavaScript functionality can be
factored out and encapsulated
Ajax Without the J
It would be nice to encapsulate all of the
JavaScript within our components, so we
don’t have to write any JavaScript.

JavaServer Faces (JSF) provides a way to
accomplish this.
JSF and AJAX
Why JSF makes sense
- JSF Lifecycle
- Separates the things that don’t change
(client-side) from the things that do
change (server-side)
- Echo2 is another Java component-based
web framework that supports AJAX.
-

http://www.nextapp.com/platform/echo2/echo/
Sun BluePrints Solutions
Catalog
Sun defines best practices for integrating
AJAX into JSF applications.
https://bpcatalog.dev.java.net/nonav/ajax/
Java Studio Creator 2
Sun has released several AJAX components that
are available for Creator 2
- Auto-Complete Text Field
- Progress Bar
- Map Viewer
- Select Value Text Field
Obtain components via Creator’s “Update Center”
Demo – Creator 2 AJAX
Components




Auto Complete
Map Viewer
Drag-and-drop components


Code server-based functionality
Demo – DWR (Direct Web
Remoting)




Call methods from a POJO that reside on
the server.
Wraps objects in a JavaScript wrapper
Links


Original AJAX Blog by Jesse James Garrett




“Fixing AJAX: XMLHttpRequest Considered Harmful”




http://www.jsfcentral.com/listings/A10500?link

Really Simple History (RSH) Framework




https://bpcatalog.dev.java.net/nonav/ajax/index.html

“AJAX Without the J” Blog




http://getahead.ltd.uk/dwr/

Java AJAX BluePrints Solutions Catalog




http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html

DWR (Direct Web Remoting) Home Page




http://adaptivepath.com/publications/essays/archives/000385.php

http://codinginparadise.org/projects/dhtml_history/README.html

ECHO 2 Web Framework
-

http://www.nextapp.com/platform/echo2/echo/
Questions


My E-mail is:
Venkat.pinagadi@gmail.com

Mais conteúdo relacionado

Mais procurados

An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programming
hchen1
 
Using Ajax In Domino Web Applications
Using Ajax In Domino Web ApplicationsUsing Ajax In Domino Web Applications
Using Ajax In Domino Web Applications
dominion
 

Mais procurados (20)

Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Ajax Ppt
Ajax PptAjax Ppt
Ajax Ppt
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
 
Ajax ppt
Ajax pptAjax ppt
Ajax ppt
 
Ajax presentation
Ajax presentationAjax presentation
Ajax presentation
 
What is Ajax technology?
What is Ajax technology?What is Ajax technology?
What is Ajax technology?
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slides
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Ajax.ppt
Ajax.pptAjax.ppt
Ajax.ppt
 
Overview of AJAX
Overview of AJAXOverview of AJAX
Overview of AJAX
 
Ajax PPT
Ajax PPTAjax PPT
Ajax PPT
 
Advantages and disadvantages of an ajax based client application
Advantages and disadvantages of an ajax based client applicationAdvantages and disadvantages of an ajax based client application
Advantages and disadvantages of an ajax based client application
 
An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programming
 
Architecture in Ajax Applications
Architecture in Ajax ApplicationsArchitecture in Ajax Applications
Architecture in Ajax Applications
 
Using Ajax In Domino Web Applications
Using Ajax In Domino Web ApplicationsUsing Ajax In Domino Web Applications
Using Ajax In Domino Web Applications
 
Jquery Ajax
Jquery AjaxJquery Ajax
Jquery Ajax
 
AJAX
AJAXAJAX
AJAX
 

Destaque

인천펜션 노보텔호텔
인천펜션 노보텔호텔인천펜션 노보텔호텔
인천펜션 노보텔호텔
jdhfrter
 
Introducción a la biotecnología
Introducción a la biotecnologíaIntroducción a la biotecnología
Introducción a la biotecnología
bkt_6
 
Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...
Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...
Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...
GUILLERMO MOLINA JARA
 

Destaque (12)

Ipsos Consumer Confidence Index April 2013
Ipsos Consumer Confidence Index April 2013Ipsos Consumer Confidence Index April 2013
Ipsos Consumer Confidence Index April 2013
 
AcreditacióN 9 SesióN
AcreditacióN 9 SesióNAcreditacióN 9 SesióN
AcreditacióN 9 SesióN
 
9 icms instructions_for_authors
9 icms instructions_for_authors9 icms instructions_for_authors
9 icms instructions_for_authors
 
IAFE Zone 3/6 - New Digital Priorities: Trends in Digital Marketing
IAFE Zone 3/6 - New Digital Priorities: Trends in Digital MarketingIAFE Zone 3/6 - New Digital Priorities: Trends in Digital Marketing
IAFE Zone 3/6 - New Digital Priorities: Trends in Digital Marketing
 
인천펜션 노보텔호텔
인천펜션 노보텔호텔인천펜션 노보텔호텔
인천펜션 노보텔호텔
 
B100 board presentation
B100 board presentationB100 board presentation
B100 board presentation
 
Introducción a la biotecnología
Introducción a la biotecnologíaIntroducción a la biotecnología
Introducción a la biotecnología
 
0406web creators night_DeNA
0406web creators night_DeNA0406web creators night_DeNA
0406web creators night_DeNA
 
Daily Newsletter: 17th May, 2011
Daily Newsletter: 17th May, 2011Daily Newsletter: 17th May, 2011
Daily Newsletter: 17th May, 2011
 
Online marketing and distribution
Online marketing and distributionOnline marketing and distribution
Online marketing and distribution
 
Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...
Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...
Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...
 
Dynamics CRM 2013 Customization and Configuration
Dynamics CRM 2013 Customization and ConfigurationDynamics CRM 2013 Customization and Configuration
Dynamics CRM 2013 Customization and Configuration
 

Semelhante a Introduction to ajax

Ajax: User Experience
Ajax: User ExperienceAjax: User Experience
Ajax: User Experience
petrov
 
Make your gui shine with ajax solr
Make your gui shine with ajax solrMake your gui shine with ajax solr
Make your gui shine with ajax solr
lucenerevolution
 
Aspnet Ajax Performance Improvement
Aspnet Ajax Performance ImprovementAspnet Ajax Performance Improvement
Aspnet Ajax Performance Improvement
Lance Zhang
 
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar TechnologiesRob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
george.james
 

Semelhante a Introduction to ajax (20)

Ajax: User Experience
Ajax: User ExperienceAjax: User Experience
Ajax: User Experience
 
Beyond HTML: Tools for Building Web 2.0 Apps
Beyond HTML: Tools for Building Web 2.0 AppsBeyond HTML: Tools for Building Web 2.0 Apps
Beyond HTML: Tools for Building Web 2.0 Apps
 
25250716 seminar-on-ajax text
25250716 seminar-on-ajax text25250716 seminar-on-ajax text
25250716 seminar-on-ajax text
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
AJAX in ASP.NET
AJAX in ASP.NETAJAX in ASP.NET
AJAX in ASP.NET
 
Ajax assignment help
Ajax assignment helpAjax assignment help
Ajax assignment help
 
Make your gui shine with ajax solr
Make your gui shine with ajax solrMake your gui shine with ajax solr
Make your gui shine with ajax solr
 
Ajax
AjaxAjax
Ajax
 
mukesh
mukeshmukesh
mukesh
 
Copy of ajax tutorial
Copy of ajax tutorialCopy of ajax tutorial
Copy of ajax tutorial
 
Ajax Introduction
Ajax IntroductionAjax Introduction
Ajax Introduction
 
Ajax
AjaxAjax
Ajax
 
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitWriting and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
 
GWT = easy AJAX
GWT = easy AJAXGWT = easy AJAX
GWT = easy AJAX
 
M Ramya
M RamyaM Ramya
M Ramya
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
Aspnet Ajax Performance Improvement
Aspnet Ajax Performance ImprovementAspnet Ajax Performance Improvement
Aspnet Ajax Performance Improvement
 
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar TechnologiesRob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Introduction to ajax

  • 2. What is Ajax?  Asynchronous  JavaScript  And  XmlHttpRequest (XHR)  Some use XML, but to me that’s misleading
  • 3. Why Ajax?  XHR Support across all browsers   Emergence of broadband    Based on DOM, CSS, XHTML AJAX-based JavaScript can take considerable bandwidth to download The “Killer App” - Google Maps A Catchy Acronym  Coined by Jesse James Garrett of Adaptive Path (February 2005)
  • 6. AJAX Alternatives  Macromedia Flash  Requires a plug-in    Java Web Start/Applets .NET – No Touch Deployment   So what? It comes already with almost every browser Both need a runtime preinstalled Handheld device browsers generally do not support the full range of Ajax technologies.
  • 7. Implementing AJAX  To implement AJAX we need to answer three questions:  What triggers the AJAX request?   What is the server process that handles the AJAX request and issues the response?   Usually a JavaScript event (onblur, onclick, etc.) 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.
  • 8. XmlHttpRequest Object (XHR)    The Heart of AJAX First implemented in IE in 1997 as part of the new DHTML standard Response comes in one of two properties:   responseXML – Returns a DOM document (can use functions such as, getElementById()) responseText – A text string (can be HTML, or even JavaScript code)
  • 10. XHR : Sending the Request true = asynchronous
  • 11. XHR : Using a callback handler
  • 12. Handling the Response  Response can be one of the following:  Formatted data (XML, other custom format)  XMLHttpRequest.responseXML    Decouples the server from presentation issues Could perform XSLT transformation on returned XML HTML  XMLHttpRequest.responseText  Server generates HTML, script “injects” HTML via innerHTML   Server is now concerned with presentation JavaScript  XMLHttpRequest.responseText  Use the eval() JavaScript command  Again, our server code is concerned with presentation
  • 14. AJAX and the Back Button     Huge usability issue Returning to the previous state may not be possible when a page is updated dynamically Difficult to bookmark on a particular page state Really Simple History (RSH) framework addresses these issues  http://codinginparadise.org/projects/dhtml_history/README.html
  • 15. AJAX Security – Server of Origin Policy
  • 16. AJAX Security  Browsers impose security restrictions  Cannot make requests via the XHR outside of the domain the web page came from Can set security on IE to get around this (but you really don’t want to)  Mozilla-based browsers require digitally signing your script (Yuck!)   User must approve going to site.  Firefox requires additional code
  • 17. AJAX Security  Calling third-party web-services   Application Proxies – Call the web-service from a servlet Apache Proxy – Configure Apache to invisibly reroute from the server to the target web service domain
  • 19. Encapsulating our AJAX Logic (cont.)
  • 20. Problems with JavaScript  Most Java developers know enough JavaScript to be dangerous.   If you don’t know what you are doing, you could cause memory leaks on the client machine. Most JavaScript functionality can be factored out and encapsulated
  • 21. Ajax Without the J It would be nice to encapsulate all of the JavaScript within our components, so we don’t have to write any JavaScript. JavaServer Faces (JSF) provides a way to accomplish this.
  • 22. JSF and AJAX Why JSF makes sense - JSF Lifecycle - Separates the things that don’t change (client-side) from the things that do change (server-side) - Echo2 is another Java component-based web framework that supports AJAX. - http://www.nextapp.com/platform/echo2/echo/
  • 23. Sun BluePrints Solutions Catalog Sun defines best practices for integrating AJAX into JSF applications. https://bpcatalog.dev.java.net/nonav/ajax/
  • 24. Java Studio Creator 2 Sun has released several AJAX components that are available for Creator 2 - Auto-Complete Text Field - Progress Bar - Map Viewer - Select Value Text Field Obtain components via Creator’s “Update Center”
  • 25. Demo – Creator 2 AJAX Components    Auto Complete Map Viewer Drag-and-drop components  Code server-based functionality
  • 26. Demo – DWR (Direct Web Remoting)   Call methods from a POJO that reside on the server. Wraps objects in a JavaScript wrapper
  • 27. Links  Original AJAX Blog by Jesse James Garrett   “Fixing AJAX: XMLHttpRequest Considered Harmful”   http://www.jsfcentral.com/listings/A10500?link Really Simple History (RSH) Framework   https://bpcatalog.dev.java.net/nonav/ajax/index.html “AJAX Without the J” Blog   http://getahead.ltd.uk/dwr/ Java AJAX BluePrints Solutions Catalog   http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html DWR (Direct Web Remoting) Home Page   http://adaptivepath.com/publications/essays/archives/000385.php http://codinginparadise.org/projects/dhtml_history/README.html ECHO 2 Web Framework - http://www.nextapp.com/platform/echo2/echo/

Notas do Editor

  1. Non-standard extensions to the web-browser DOM.
  2. Non-standard extensions to the web-browser DOM.
  3. Non-standard extensions to the web-browser DOM.