SlideShare una empresa de Scribd logo
1 de 20
Ajax
      by
K.SIVA KUMAR
AJAX = Asynchronous JavaScript and
XML.
AJAX is not a new programming
language, but a new way to use existing
standards.
AJAX is the art of exchanging data with a
server, and update parts of a web page -
without reloading the whole page.
AJAX is about updating parts of a web
page, without reloading the whole page.
What You Should Already Know
Before you continue you should have a
basic understanding of the following:
HTML / XHTML
CSS
JavaScript / DOM
Rich Internet Application (RIA) Technology
AJAX is most viable RIA technology so far. Its getting tremendous industry
momentum and several toolkit and framworks areemerging. But same time
JAX has browser incompatibility and it is supported by Java Script which is
hard to maintain nand debug.
AJAX Is Based On Open Standards
AJAX is based on the following open standards:
Browser-based presentation using HTML and Cascading Style Sheets
(CSS)
Data stored in XML format and fetched from the server
Behind-the-scenes data fetches using XMLHttpRequest objects in the
browser
JavaScript to make everything happen
AJAX - Recommended Knowledge
It is highly recommended that you are familiar with HTML and Javascript
before attempting this tutorial.
JavaScript
Loosely typed scripting language
JavaScript function is called when an event in a page occurs
Glue for the whole AJAX operation
DOM
API for accessing and manipulating structured documents
Represents the structure of XML and HTML documents
CSS
Allows for a clear separation of the presentation style from the
content and may be changed programmatically by JavaScript
XMLHttpRequest
JavaScript object that performs asynchrous interaction with the
server
Here is the list of famous web applications which are using AJAX
Google Maps
A user can drag the entire map by using the mouse instead of clicking on a
button or something
http://maps.google.com/
Google Suggest
As you type, Google will offer suggestions. Use the arrow keys to navigate
the results
http://www.google.com/webhp?complete=1&hl=en
Gmail
Gmail is a new kind of webmail, built on the idea that email can be more
intuitive, efficient and useful
http://gmail.com/
Yahoo Maps (new)
Now it's even easier and more fun to get where you're going!
http://maps.yahoo.com/
Google Suggest
AJAX was made popular in 2005 by
Google, with Google Suggest.
Google Suggest is using AJAX to create a
very dynamic web interface: When you
start typing in Google's search box, a
JavaScript sends the letters off to a server
and the server returns a list of
suggestions.
The keystone of AJAX is the XMLHttpRequest
object.
The XMLHttpRequest Object
All modern browsers support the
XMLHttpRequest object (IE5 and IE6 use an
ActiveXObject).
The XMLHttpRequest object is used to
exchange data with a server behind the scenes.
This means that it is possible to update parts of
a web page, without reloading the whole page.
Create an XMLHttpRequest Object
All modern browsers (IE7+, Firefox, Chrome, Safari, and
Opera) have a built-in XMLHttpRequest object.
Syntax for creating an XMLHttpRequest object:
variable=new XMLHttpRequest();
Old versions of Internet Explorer (IE5 and IE6) uses an
ActiveX Object:
variable=new ActiveXObject("Microsoft.XMLHTTP");
To handle all modern browsers, including IE5 and IE6,
check if the browser supports the XMLHttpRequest
object. If it does, create an XMLHttpRequest object, if
not, create an ActiveXObject:
The XMLHttpRequest object is used to exchange data with a server.
Send a Request To a Server
To send a request to a server, we use the open() and send()
methods of the XMLHttpRequest object:
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();

MethodDescriptionopen(method,url,async)Specifies the type of
request, the URL, and if the request should be handled
asynchronously or not.
method: the type of request: GET or POST
url: the location of the file on the server
async: true (asynchronous) or false
(synchronous)send(string)Sends the request off to the server.
string: Only used for POST requests
GET or POST?
GET is simpler and faster than POST, and can
be used in most cases.
However, always use POST requests when:
A cached file is not an option (update a file or
database on the server)
Sending a large amount of data to the server
(POST has no size limitations)
Sending user input (which can contain unknown
characters), POST is more robust and secure
than GET
Asynchronous - True or False?
Async=true
With AJAX, the JavaScript does not have
to wait for the server response, but can
instead:
execute other scripts while waiting for
server response
deal with the response when the response
ready
Async=false
Using async=false is not recommended, but for
a few small requests this can be ok.
Remember that the JavaScript will NOT continue
to execute, until the server response is ready. If
the server is busy or slow, the application will
hang or stop.
Note: When you use async=false, do NOT write
an onreadystatechange function - just put the
code after the send() statement
Server Response
  To get the response from a server, use the responseText
  or responseXML property of the XMLHttpRequest object.
  Property           Description
  responseText       get the response data as a string
  responseXML        get the response data as XML data
The responseText Property
  If the response from the server is not XML, use the
  responseText property.
  The responseText property returns the response as a
  string, and you can use it accordingly
The responseXML Property
If the response from the server is XML,
and you want to parse it as an XML object,
use the responseXML property:
The onreadystatechange event
When a request to a server is sent, we
want to perform some actions based on
the response.
The onreadystatechange event is
triggered every time the readyState
changes.
The readyState property holds the status
of the XMLHttpRequest.
Three important properties of the XMLHttpRequest object:
Property                   Description
Onreadystatechange Stores a function (or the name of a
                      function) to be called automatically each time
                      the readyState property changes
readyState            Holds the status of the XMLHttpRequest.
                      Changes from 0 to 4:
                      0: request not initialized
                      1: server connection established
                      2: request received
                      3: processing request
                      4: request finished and response is ready
Status                200: "OK"
                      404: Page not found
In the onreadystatechange event, we
specify what will happen when the server
response is ready to be processed.
When readyState is 4 and status is 200,
the response is ready
Note: The onreadystatechange event is
triggered four times, one time for each
change in readyState.
Using a Callback Function
 A callback function is a function passed as a
  parameter to another function.
 If you have more than one AJAX task on your
  website, you should create ONE standard
  function for creating the XMLHttpRequest object,
  and call this for each AJAX task.
 The function call should contain the URL and
  what to do on onreadystatechange (which is
  probably different for each call):

Más contenido relacionado

La actualidad más candente (20)

Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Inner core of Ajax
Inner core of Ajax Inner core of Ajax
Inner core of Ajax
 
Introduction To Asp.Net Ajax
Introduction To Asp.Net AjaxIntroduction To Asp.Net Ajax
Introduction To Asp.Net Ajax
 
Ajax and PHP
Ajax and PHPAjax and PHP
Ajax and PHP
 
M Ramya
M RamyaM Ramya
M Ramya
 
Ajax Ppt
Ajax PptAjax Ppt
Ajax Ppt
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Microsoft Azure Web Sites Performance Analysis Lessons Learned
Microsoft Azure Web Sites Performance Analysis Lessons LearnedMicrosoft Azure Web Sites Performance Analysis Lessons Learned
Microsoft Azure Web Sites Performance Analysis Lessons Learned
 
Ajax
AjaxAjax
Ajax
 
Ajax
Ajax Ajax
Ajax
 
Ajax control asp.net
Ajax control asp.netAjax control asp.net
Ajax control asp.net
 
Ajax Introduction Presentation
Ajax   Introduction   PresentationAjax   Introduction   Presentation
Ajax Introduction Presentation
 
Ajax Presentation
Ajax PresentationAjax Presentation
Ajax Presentation
 
Ajax & ASP.NET 2
Ajax & ASP.NET 2Ajax & ASP.NET 2
Ajax & ASP.NET 2
 
Apex code (Salesforce)
Apex code (Salesforce)Apex code (Salesforce)
Apex code (Salesforce)
 
Ajax presentation
Ajax presentationAjax presentation
Ajax presentation
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Copy of ajax tutorial
Copy of ajax tutorialCopy of ajax tutorial
Copy of ajax tutorial
 
Asp.Net Database
Asp.Net DatabaseAsp.Net Database
Asp.Net Database
 
Rack
RackRack
Rack
 

Destacado

Guia de trabajo 3, el modulo solar fotovoltaico
Guia de trabajo 3, el modulo solar fotovoltaicoGuia de trabajo 3, el modulo solar fotovoltaico
Guia de trabajo 3, el modulo solar fotovoltaicoguillermo rojas
 
ReCap: Graphic Recordings Marketing Rockstars 2015
ReCap: Graphic Recordings Marketing Rockstars 2015ReCap: Graphic Recordings Marketing Rockstars 2015
ReCap: Graphic Recordings Marketing Rockstars 2015VerVieVas Erklärvideos
 
Revista Alba Longa 16 (2011-2012)
Revista Alba Longa 16 (2011-2012)Revista Alba Longa 16 (2011-2012)
Revista Alba Longa 16 (2011-2012)alquipir1
 
Jornadas de Puertas Abiertas 2013- Ruta do Viño Rías Baixas
Jornadas de Puertas Abiertas 2013- Ruta do Viño Rías BaixasJornadas de Puertas Abiertas 2013- Ruta do Viño Rías Baixas
Jornadas de Puertas Abiertas 2013- Ruta do Viño Rías BaixasRuta do Viño Rías Baixas
 
Executive Search. Modelo de Consultoría y Servicio
Executive Search. Modelo de Consultoría y ServicioExecutive Search. Modelo de Consultoría y Servicio
Executive Search. Modelo de Consultoría y ServicioCarlos Narvarte Fischmann
 
Sbc the-critical-component for a successful IP PBX Deloyment
Sbc the-critical-component for a successful IP PBX DeloymentSbc the-critical-component for a successful IP PBX Deloyment
Sbc the-critical-component for a successful IP PBX DeloymentSelf Employed
 
Pancreatitis aguda severa
Pancreatitis aguda severaPancreatitis aguda severa
Pancreatitis aguda severaTeressa Silva
 
Phan mem plc s7 1200 opc simatic-net-e
Phan mem plc s7 1200 opc simatic-net-ePhan mem plc s7 1200 opc simatic-net-e
Phan mem plc s7 1200 opc simatic-net-eBùi Thể
 
Furnitre mms-iv-marketing-pramod vishwakarma
Furnitre mms-iv-marketing-pramod vishwakarmaFurnitre mms-iv-marketing-pramod vishwakarma
Furnitre mms-iv-marketing-pramod vishwakarmapramod vishwakarma
 
Computer forensics law and privacy
Computer forensics   law and privacyComputer forensics   law and privacy
Computer forensics law and privacych samaram
 
Reto de Innovación. Preguntas creativas
Reto de Innovación. Preguntas creativasReto de Innovación. Preguntas creativas
Reto de Innovación. Preguntas creativasClever Energy
 
Estadías hospital universitario
Estadías hospital universitario Estadías hospital universitario
Estadías hospital universitario Ernesto Gtz
 
Pgdsd admission brochure
Pgdsd admission brochurePgdsd admission brochure
Pgdsd admission brochurebikram ...
 
Coporate Fundraising bei der Johanniter-Unfall-Hilfe
Coporate Fundraising bei der Johanniter-Unfall-Hilfe Coporate Fundraising bei der Johanniter-Unfall-Hilfe
Coporate Fundraising bei der Johanniter-Unfall-Hilfe Anna Maria Wagner
 
Opening remarks by Dr Mohamed Ait-Kadi, GWP Technical Committee Chair
Opening remarks by Dr Mohamed Ait-Kadi, GWP Technical Committee ChairOpening remarks by Dr Mohamed Ait-Kadi, GWP Technical Committee Chair
Opening remarks by Dr Mohamed Ait-Kadi, GWP Technical Committee ChairGlobal Water Partnership
 

Destacado (20)

Guia de trabajo 3, el modulo solar fotovoltaico
Guia de trabajo 3, el modulo solar fotovoltaicoGuia de trabajo 3, el modulo solar fotovoltaico
Guia de trabajo 3, el modulo solar fotovoltaico
 
ReCap: Graphic Recordings Marketing Rockstars 2015
ReCap: Graphic Recordings Marketing Rockstars 2015ReCap: Graphic Recordings Marketing Rockstars 2015
ReCap: Graphic Recordings Marketing Rockstars 2015
 
Revista Alba Longa 16 (2011-2012)
Revista Alba Longa 16 (2011-2012)Revista Alba Longa 16 (2011-2012)
Revista Alba Longa 16 (2011-2012)
 
Jornadas de Puertas Abiertas 2013- Ruta do Viño Rías Baixas
Jornadas de Puertas Abiertas 2013- Ruta do Viño Rías BaixasJornadas de Puertas Abiertas 2013- Ruta do Viño Rías Baixas
Jornadas de Puertas Abiertas 2013- Ruta do Viño Rías Baixas
 
Telephoning2
Telephoning2Telephoning2
Telephoning2
 
Executive Search. Modelo de Consultoría y Servicio
Executive Search. Modelo de Consultoría y ServicioExecutive Search. Modelo de Consultoría y Servicio
Executive Search. Modelo de Consultoría y Servicio
 
P6010 Manual
P6010 ManualP6010 Manual
P6010 Manual
 
Sbc the-critical-component for a successful IP PBX Deloyment
Sbc the-critical-component for a successful IP PBX DeloymentSbc the-critical-component for a successful IP PBX Deloyment
Sbc the-critical-component for a successful IP PBX Deloyment
 
Pancreatitis aguda severa
Pancreatitis aguda severaPancreatitis aguda severa
Pancreatitis aguda severa
 
Phan mem plc s7 1200 opc simatic-net-e
Phan mem plc s7 1200 opc simatic-net-ePhan mem plc s7 1200 opc simatic-net-e
Phan mem plc s7 1200 opc simatic-net-e
 
10 years of academies
10 years of academies10 years of academies
10 years of academies
 
Furnitre mms-iv-marketing-pramod vishwakarma
Furnitre mms-iv-marketing-pramod vishwakarmaFurnitre mms-iv-marketing-pramod vishwakarma
Furnitre mms-iv-marketing-pramod vishwakarma
 
Computer forensics law and privacy
Computer forensics   law and privacyComputer forensics   law and privacy
Computer forensics law and privacy
 
Catalogo
CatalogoCatalogo
Catalogo
 
Reto de Innovación. Preguntas creativas
Reto de Innovación. Preguntas creativasReto de Innovación. Preguntas creativas
Reto de Innovación. Preguntas creativas
 
Abstract 2015
Abstract 2015Abstract 2015
Abstract 2015
 
Estadías hospital universitario
Estadías hospital universitario Estadías hospital universitario
Estadías hospital universitario
 
Pgdsd admission brochure
Pgdsd admission brochurePgdsd admission brochure
Pgdsd admission brochure
 
Coporate Fundraising bei der Johanniter-Unfall-Hilfe
Coporate Fundraising bei der Johanniter-Unfall-Hilfe Coporate Fundraising bei der Johanniter-Unfall-Hilfe
Coporate Fundraising bei der Johanniter-Unfall-Hilfe
 
Opening remarks by Dr Mohamed Ait-Kadi, GWP Technical Committee Chair
Opening remarks by Dr Mohamed Ait-Kadi, GWP Technical Committee ChairOpening remarks by Dr Mohamed Ait-Kadi, GWP Technical Committee Chair
Opening remarks by Dr Mohamed Ait-Kadi, GWP Technical Committee Chair
 

Similar a Ajax (20)

AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
 
Core Java tutorial at Unit Nexus
Core Java tutorial at Unit NexusCore Java tutorial at Unit Nexus
Core Java tutorial at Unit Nexus
 
Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)
 
Ajax
AjaxAjax
Ajax
 
AJAX
AJAXAJAX
AJAX
 
Unit-5.pptx
Unit-5.pptxUnit-5.pptx
Unit-5.pptx
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Mashup
MashupMashup
Mashup
 
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
 
Introduction about-ajax-framework
Introduction about-ajax-frameworkIntroduction about-ajax-framework
Introduction about-ajax-framework
 
Ajax
AjaxAjax
Ajax
 
Ajax tutorial by bally chohan
Ajax tutorial by bally chohanAjax tutorial by bally chohan
Ajax tutorial by bally chohan
 
PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 

Más de ch samaram

Syllabus r10-ecm-42-network security and cryptography
 Syllabus r10-ecm-42-network security and cryptography Syllabus r10-ecm-42-network security and cryptography
Syllabus r10-ecm-42-network security and cryptographych samaram
 
Restaurant billing application
Restaurant billing applicationRestaurant billing application
Restaurant billing applicationch samaram
 
Spintronics (1)
Spintronics (1)Spintronics (1)
Spintronics (1)ch samaram
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoftch samaram
 
Basics java scripts
Basics java scriptsBasics java scripts
Basics java scriptsch samaram
 

Más de ch samaram (17)

Syllabus r10-ecm-42-network security and cryptography
 Syllabus r10-ecm-42-network security and cryptography Syllabus r10-ecm-42-network security and cryptography
Syllabus r10-ecm-42-network security and cryptography
 
Restaurant billing application
Restaurant billing applicationRestaurant billing application
Restaurant billing application
 
Spintronics
SpintronicsSpintronics
Spintronics
 
Spintronics (1)
Spintronics (1)Spintronics (1)
Spintronics (1)
 
Shore
ShoreShore
Shore
 
Presentation
PresentationPresentation
Presentation
 
Open gl
Open glOpen gl
Open gl
 
Opengl (1)
Opengl (1)Opengl (1)
Opengl (1)
 
Blue gene
Blue geneBlue gene
Blue gene
 
Blue gene
Blue geneBlue gene
Blue gene
 
Wearable (1)
Wearable (1)Wearable (1)
Wearable (1)
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
 
Html siva
Html sivaHtml siva
Html siva
 
Css siva
Css sivaCss siva
Css siva
 
Basics java scripts
Basics java scriptsBasics java scripts
Basics java scripts
 
Html 5
Html 5Html 5
Html 5
 
Css siva
Css sivaCss siva
Css siva
 

Ajax

  • 1. Ajax by K.SIVA KUMAR
  • 2. AJAX = Asynchronous JavaScript and XML. AJAX is not a new programming language, but a new way to use existing standards. AJAX is the art of exchanging data with a server, and update parts of a web page - without reloading the whole page.
  • 3. AJAX is about updating parts of a web page, without reloading the whole page. What You Should Already Know Before you continue you should have a basic understanding of the following: HTML / XHTML CSS JavaScript / DOM
  • 4. Rich Internet Application (RIA) Technology AJAX is most viable RIA technology so far. Its getting tremendous industry momentum and several toolkit and framworks areemerging. But same time JAX has browser incompatibility and it is supported by Java Script which is hard to maintain nand debug. AJAX Is Based On Open Standards AJAX is based on the following open standards: Browser-based presentation using HTML and Cascading Style Sheets (CSS) Data stored in XML format and fetched from the server Behind-the-scenes data fetches using XMLHttpRequest objects in the browser JavaScript to make everything happen AJAX - Recommended Knowledge It is highly recommended that you are familiar with HTML and Javascript before attempting this tutorial.
  • 5. JavaScript Loosely typed scripting language JavaScript function is called when an event in a page occurs Glue for the whole AJAX operation DOM API for accessing and manipulating structured documents Represents the structure of XML and HTML documents CSS Allows for a clear separation of the presentation style from the content and may be changed programmatically by JavaScript XMLHttpRequest JavaScript object that performs asynchrous interaction with the server
  • 6. Here is the list of famous web applications which are using AJAX Google Maps A user can drag the entire map by using the mouse instead of clicking on a button or something http://maps.google.com/ Google Suggest As you type, Google will offer suggestions. Use the arrow keys to navigate the results http://www.google.com/webhp?complete=1&hl=en Gmail Gmail is a new kind of webmail, built on the idea that email can be more intuitive, efficient and useful http://gmail.com/ Yahoo Maps (new) Now it's even easier and more fun to get where you're going! http://maps.yahoo.com/
  • 7.
  • 8. Google Suggest AJAX was made popular in 2005 by Google, with Google Suggest. Google Suggest is using AJAX to create a very dynamic web interface: When you start typing in Google's search box, a JavaScript sends the letters off to a server and the server returns a list of suggestions.
  • 9. The keystone of AJAX is the XMLHttpRequest object. The XMLHttpRequest Object All modern browsers support the XMLHttpRequest object (IE5 and IE6 use an ActiveXObject). The XMLHttpRequest object is used to exchange data with a server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.
  • 10. Create an XMLHttpRequest Object All modern browsers (IE7+, Firefox, Chrome, Safari, and Opera) have a built-in XMLHttpRequest object. Syntax for creating an XMLHttpRequest object: variable=new XMLHttpRequest(); Old versions of Internet Explorer (IE5 and IE6) uses an ActiveX Object: variable=new ActiveXObject("Microsoft.XMLHTTP"); To handle all modern browsers, including IE5 and IE6, check if the browser supports the XMLHttpRequest object. If it does, create an XMLHttpRequest object, if not, create an ActiveXObject:
  • 11. The XMLHttpRequest object is used to exchange data with a server. Send a Request To a Server To send a request to a server, we use the open() and send() methods of the XMLHttpRequest object: xmlhttp.open("GET","ajax_info.txt",true); xmlhttp.send(); MethodDescriptionopen(method,url,async)Specifies the type of request, the URL, and if the request should be handled asynchronously or not. method: the type of request: GET or POST url: the location of the file on the server async: true (asynchronous) or false (synchronous)send(string)Sends the request off to the server. string: Only used for POST requests
  • 12. GET or POST? GET is simpler and faster than POST, and can be used in most cases. However, always use POST requests when: A cached file is not an option (update a file or database on the server) Sending a large amount of data to the server (POST has no size limitations) Sending user input (which can contain unknown characters), POST is more robust and secure than GET
  • 13. Asynchronous - True or False? Async=true With AJAX, the JavaScript does not have to wait for the server response, but can instead: execute other scripts while waiting for server response deal with the response when the response ready
  • 14. Async=false Using async=false is not recommended, but for a few small requests this can be ok. Remember that the JavaScript will NOT continue to execute, until the server response is ready. If the server is busy or slow, the application will hang or stop. Note: When you use async=false, do NOT write an onreadystatechange function - just put the code after the send() statement
  • 15. Server Response To get the response from a server, use the responseText or responseXML property of the XMLHttpRequest object. Property Description responseText get the response data as a string responseXML get the response data as XML data The responseText Property If the response from the server is not XML, use the responseText property. The responseText property returns the response as a string, and you can use it accordingly
  • 16. The responseXML Property If the response from the server is XML, and you want to parse it as an XML object, use the responseXML property:
  • 17. The onreadystatechange event When a request to a server is sent, we want to perform some actions based on the response. The onreadystatechange event is triggered every time the readyState changes. The readyState property holds the status of the XMLHttpRequest.
  • 18. Three important properties of the XMLHttpRequest object: Property Description Onreadystatechange Stores a function (or the name of a function) to be called automatically each time the readyState property changes readyState Holds the status of the XMLHttpRequest. Changes from 0 to 4: 0: request not initialized 1: server connection established 2: request received 3: processing request 4: request finished and response is ready Status 200: "OK" 404: Page not found
  • 19. In the onreadystatechange event, we specify what will happen when the server response is ready to be processed. When readyState is 4 and status is 200, the response is ready Note: The onreadystatechange event is triggered four times, one time for each change in readyState.
  • 20. Using a Callback Function  A callback function is a function passed as a parameter to another function.  If you have more than one AJAX task on your website, you should create ONE standard function for creating the XMLHttpRequest object, and call this for each AJAX task.  The function call should contain the URL and what to do on onreadystatechange (which is probably different for each call):