-----------------
Asynchornized javascript and XML. It is used to retrive the data without refresh the page
or reloading page dynamically.
2. What type of status and readystate avaliable in Ajax?
--------------------------------------------------------
a. Ready state
0 - Request is not initilized
1 - Server connection establized (loading)
2 - Request Received (loaded)
3 - Processing Request (Interactive)
4 - Request Finished and response is ready (complete)
b. status
200 code - ok
404 code - page not found
3. XMLHttpRequest Object
----------------------------
It is used to exchange the data with server behind the page
New version Syntax
==================
xmlhttp=new XMLHttpRequest();
old version syntax
===================
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
a. XMLHttpRequest object have two methods:
1. open(method,url,async)
method: the type of request: GET or POST
url: the location of the file on the server
async: true (asynchronous) or false (synchronous)
2.send(string)
Sends the request off to the server.
string: Only used for POST requests
readyState the code successively changes value from 0 to 4 that means for "ready".
0 - Request is not initilized
1 - Server connection establized (loading)
2 - Request Received (loaded)
3 - Processing Request (Interactive)
4 - Request Finished and response is ready (complete)
b. status
200 code - ok
404 code - page not found
3. XMLHttpRequest Object
----------------------------
It is used to exchange the data with server behind the page
New version Syntax
==================
xmlhttp=new XMLHttpRequest();
old version syntax
===================
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
a. XMLHttpRequest object have two methods:
1. open(method,url,async)
method: the type of request: GET or POST
url: the location of the file on the server
async: true (asynchronous) or false (synchronous)
2.send(string)
Sends the request off to the server.
string: Only used for POST requests
b. XMLHttpRequest object Attribute
status 200 is OK
404 if the page is not found. responseText holds loaded data as a string of characters.
responseXml holds an XML loaded file, DOM's method allows to extract data. onreadystatechange property that takes a function as value that is invoked when the readystatechange event is dispatched.
4. Server Response
================
To get the response from a server, use the responseText or responseXML property of the XMLHttpRequst object.
a. responseText
document.getElementById("resultDiv").innerHTML=xmlhttp.responseText;
b. responseXML
xmlDoc=xmlhttp.responseXML;
No comments:
Post a Comment