SlideShare uma empresa Scribd logo
1 de 10
History
 1990 – Applets
 1999 – ActiveX Control in IE5
 2004 – Ajax (gMail & gMaps)
 2006 - W3C Spec
When Ajax Needed
 Real-time form data validation
 Autocompletion
 Load on demand
 Sophisticated user interface controls and effects
 Refreshing data and server push
 Partial submit
 Page as an application
Technologies
 HTML and CSS for presentation
 The Document Object Model (DOM) for dynamic display
  of and interaction with data
 XML for the interchange of data
 The XMLHttpRequest object for asynchronous
  communication
 JavaScript to bring these technologies together
How Ajax Works
The Anatomy of an Ajax Interaction
                      1. A client event occurs.

                      2. An XMLHttpRequest object is
                      created and configured.

                      3. The XMLHttpRequest object
                      makes a call.

                      4. The request is processed by the
                      ValidateServlet.

                      5. The ValidateServlet returns an
                      XML document containing the
                      result.

                      6. The XMLHttpRequest object calls the
                      callback() function and processes the
                      result.

                      7. The HTML DOM is updated.
Creating XMLHttpRequest Object
var oReq = new XMLHttpRequest;

function getXMLHttpRequest() {
  if (window.XMLHttpRequest) {
     return new window.XMLHttpRequest;
  }
  else {
     try {
        return new ActiveXObject("MSXML2.XMLHTTP.3.0");
     }
     catch (ex) {
        return null;
     }
  }
}
Attributes
readyState           The readyState code changes value
                     from 0 to 4 during a request cycle:
                     0: not initialized.
                     1: connection established.
                     2: request received.
                     3: processing.
                     4: finished and response is ready.
status               200: "OK"
                     404: Page not found.
onreadystatechange   callback method assigned via this
                     attribute
responseText         holds the response data as a string of
                     characters.
responseXml          holds the response data as XML data.
Methods
open(mode, url, boolean)   mode: type of request: GET or POST
                           url: the location of the file
                           boolean: true (asynchronous) or false
                           (synchronous).
send("string")             null for a GET command (in native
                           mode; null not passed with ActiveX




Example
Drawbacks
 Cannot use back button on browser
                Example

 Dynamic web page updates also make it difficult
  to bookmark and return to a particular state of the
  application.
 The asynchronous callback-style of programming
  required can lead to complex code that is hard to
  maintain, debug and test

Mais conteúdo relacionado

Mais procurados

React JS and Redux
React JS and ReduxReact JS and Redux
React JS and ReduxGlib Kechyn
 
React.js and Redux overview
React.js and Redux overviewReact.js and Redux overview
React.js and Redux overviewAlex Bachuk
 
Mule json transformers
Mule json transformersMule json transformers
Mule json transformersveena naresh
 
8\9 SSIS 2008R2_Training - Debugging_Package
8\9 SSIS 2008R2_Training - Debugging_Package8\9 SSIS 2008R2_Training - Debugging_Package
8\9 SSIS 2008R2_Training - Debugging_PackagePramod Singla
 
JSON Processing and mule
JSON Processing and muleJSON Processing and mule
JSON Processing and muleSanthosh Gowd
 
React state managmenet with Redux
React state managmenet with ReduxReact state managmenet with Redux
React state managmenet with ReduxVedran Blaženka
 
SQL Server 2005 CLR Integration
SQL Server 2005 CLR IntegrationSQL Server 2005 CLR Integration
SQL Server 2005 CLR Integrationwebhostingguy
 
Hibernate concurrency
Hibernate concurrencyHibernate concurrency
Hibernate concurrencypriyank09
 
9781305078444 ppt ch06
9781305078444 ppt ch069781305078444 ppt ch06
9781305078444 ppt ch06Terry Yoast
 
An Introduction to ReactJS
An Introduction to ReactJSAn Introduction to ReactJS
An Introduction to ReactJSAll Things Open
 
Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with ReduxFITC
 
Share pointtechies linqtosp-andsbs
Share pointtechies linqtosp-andsbsShare pointtechies linqtosp-andsbs
Share pointtechies linqtosp-andsbsShakir Majeed Khan
 
Vb database connections
Vb database connectionsVb database connections
Vb database connectionsTharsikan
 
Academy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & ToolingAcademy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & ToolingBinary Studio
 

Mais procurados (19)

React JS and Redux
React JS and ReduxReact JS and Redux
React JS and Redux
 
React JS - Introduction
React JS - IntroductionReact JS - Introduction
React JS - Introduction
 
React.js and Redux overview
React.js and Redux overviewReact.js and Redux overview
React.js and Redux overview
 
Mule json transformers
Mule json transformersMule json transformers
Mule json transformers
 
8\9 SSIS 2008R2_Training - Debugging_Package
8\9 SSIS 2008R2_Training - Debugging_Package8\9 SSIS 2008R2_Training - Debugging_Package
8\9 SSIS 2008R2_Training - Debugging_Package
 
JSON Processing and mule
JSON Processing and muleJSON Processing and mule
JSON Processing and mule
 
React state managmenet with Redux
React state managmenet with ReduxReact state managmenet with Redux
React state managmenet with Redux
 
SQL Server 2005 CLR Integration
SQL Server 2005 CLR IntegrationSQL Server 2005 CLR Integration
SQL Server 2005 CLR Integration
 
mediator
mediatormediator
mediator
 
React & Redux
React & ReduxReact & Redux
React & Redux
 
Hibernate concurrency
Hibernate concurrencyHibernate concurrency
Hibernate concurrency
 
Core Java tutorial at Unit Nexus
Core Java tutorial at Unit NexusCore Java tutorial at Unit Nexus
Core Java tutorial at Unit Nexus
 
9781305078444 ppt ch06
9781305078444 ppt ch069781305078444 ppt ch06
9781305078444 ppt ch06
 
An Introduction to ReactJS
An Introduction to ReactJSAn Introduction to ReactJS
An Introduction to ReactJS
 
Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with Redux
 
Share pointtechies linqtosp-andsbs
Share pointtechies linqtosp-andsbsShare pointtechies linqtosp-andsbs
Share pointtechies linqtosp-andsbs
 
Ajax
AjaxAjax
Ajax
 
Vb database connections
Vb database connectionsVb database connections
Vb database connections
 
Academy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & ToolingAcademy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & Tooling
 

Destaque

Design Principles
Design PrinciplesDesign Principles
Design Principleskeithallyn
 
Elements of an Essay - Writing an Introduction Paragraph
Elements of an Essay - Writing an Introduction ParagraphElements of an Essay - Writing an Introduction Paragraph
Elements of an Essay - Writing an Introduction ParagraphOxford Tutoring
 
Chapter 8 cold war
Chapter 8 cold warChapter 8 cold war
Chapter 8 cold warBrown Cdg
 
The Cold War
The  Cold  WarThe  Cold  War
The Cold WarBen Dover
 
4 Biggest Challenges for Creative Teams
4 Biggest Challenges for Creative Teams4 Biggest Challenges for Creative Teams
4 Biggest Challenges for Creative TeamsWrike
 
Essential things that should always be in your car
Essential things that should always be in your carEssential things that should always be in your car
Essential things that should always be in your carEason Chan
 
The Near Future of CSS
The Near Future of CSSThe Near Future of CSS
The Near Future of CSSRachel Andrew
 
Classroom Management Tips for Kids and Adolescents
Classroom Management Tips for Kids and AdolescentsClassroom Management Tips for Kids and Adolescents
Classroom Management Tips for Kids and AdolescentsShelly Sanchez Terrell
 

Destaque (13)

Vietnam Powerpoint
Vietnam PowerpointVietnam Powerpoint
Vietnam Powerpoint
 
Design Principles
Design PrinciplesDesign Principles
Design Principles
 
Design Principles
Design PrinciplesDesign Principles
Design Principles
 
Elements of an Essay - Writing an Introduction Paragraph
Elements of an Essay - Writing an Introduction ParagraphElements of an Essay - Writing an Introduction Paragraph
Elements of an Essay - Writing an Introduction Paragraph
 
Little red ridinghood
Little red ridinghoodLittle red ridinghood
Little red ridinghood
 
Chapter 8 cold war
Chapter 8 cold warChapter 8 cold war
Chapter 8 cold war
 
The Cold War
The  Cold  WarThe  Cold  War
The Cold War
 
Cold war
Cold warCold war
Cold war
 
4 Biggest Challenges for Creative Teams
4 Biggest Challenges for Creative Teams4 Biggest Challenges for Creative Teams
4 Biggest Challenges for Creative Teams
 
Back-to-School Survey 2016
Back-to-School Survey 2016Back-to-School Survey 2016
Back-to-School Survey 2016
 
Essential things that should always be in your car
Essential things that should always be in your carEssential things that should always be in your car
Essential things that should always be in your car
 
The Near Future of CSS
The Near Future of CSSThe Near Future of CSS
The Near Future of CSS
 
Classroom Management Tips for Kids and Adolescents
Classroom Management Tips for Kids and AdolescentsClassroom Management Tips for Kids and Adolescents
Classroom Management Tips for Kids and Adolescents
 

Semelhante a Ajax (20)

Ajax Tuturial
Ajax TuturialAjax Tuturial
Ajax Tuturial
 
Unit-5.pptx
Unit-5.pptxUnit-5.pptx
Unit-5.pptx
 
AJAX
AJAXAJAX
AJAX
 
Ajax tutorial by bally chohan
Ajax tutorial by bally chohanAjax tutorial by bally chohan
Ajax tutorial by bally chohan
 
AJAX
AJAXAJAX
AJAX
 
AJAX
AJAXAJAX
AJAX
 
AJAX Transport Layer
AJAX Transport LayerAJAX Transport Layer
AJAX Transport Layer
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)
 
Ajax
AjaxAjax
Ajax
 
Ajax Technology
Ajax TechnologyAjax Technology
Ajax Technology
 
Ajax and xml
Ajax and xmlAjax and xml
Ajax and xml
 
Ajax
AjaxAjax
Ajax
 
Ajax Lecture Notes
Ajax Lecture NotesAjax Lecture Notes
Ajax Lecture Notes
 
Ajax
AjaxAjax
Ajax
 
jQuery - Chapter 5 - Ajax
jQuery - Chapter 5 -  AjaxjQuery - Chapter 5 -  Ajax
jQuery - Chapter 5 - Ajax
 
Introduction to Ajax programming
Introduction to Ajax programmingIntroduction to Ajax programming
Introduction to Ajax programming
 
Ajax
AjaxAjax
Ajax
 
AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
 

Ajax

  • 1.
  • 2. History  1990 – Applets  1999 – ActiveX Control in IE5  2004 – Ajax (gMail & gMaps)  2006 - W3C Spec
  • 3. When Ajax Needed  Real-time form data validation  Autocompletion  Load on demand  Sophisticated user interface controls and effects  Refreshing data and server push  Partial submit  Page as an application
  • 4. Technologies  HTML and CSS for presentation  The Document Object Model (DOM) for dynamic display of and interaction with data  XML for the interchange of data  The XMLHttpRequest object for asynchronous communication  JavaScript to bring these technologies together
  • 6. The Anatomy of an Ajax Interaction 1. A client event occurs. 2. An XMLHttpRequest object is created and configured. 3. The XMLHttpRequest object makes a call. 4. The request is processed by the ValidateServlet. 5. The ValidateServlet returns an XML document containing the result. 6. The XMLHttpRequest object calls the callback() function and processes the result. 7. The HTML DOM is updated.
  • 7. Creating XMLHttpRequest Object var oReq = new XMLHttpRequest; function getXMLHttpRequest() { if (window.XMLHttpRequest) { return new window.XMLHttpRequest; } else { try { return new ActiveXObject("MSXML2.XMLHTTP.3.0"); } catch (ex) { return null; } } }
  • 8. Attributes readyState The readyState code changes value from 0 to 4 during a request cycle: 0: not initialized. 1: connection established. 2: request received. 3: processing. 4: finished and response is ready. status 200: "OK" 404: Page not found. onreadystatechange callback method assigned via this attribute responseText holds the response data as a string of characters. responseXml holds the response data as XML data.
  • 9. Methods open(mode, url, boolean) mode: type of request: GET or POST url: the location of the file boolean: true (asynchronous) or false (synchronous). send("string") null for a GET command (in native mode; null not passed with ActiveX Example
  • 10. Drawbacks  Cannot use back button on browser Example  Dynamic web page updates also make it difficult to bookmark and return to a particular state of the application.  The asynchronous callback-style of programming required can lead to complex code that is hard to maintain, debug and test