Вы находитесь на странице: 1из 27

AJAX

INTRODUCTION,BENEFITS,CONS,SECURITY,METHODS,PROPERTIES
MEMBERS
TUSHAR PALIT
(59)

ANKIT SHUBHAM
NANDAN(12) SINGH(56)

HARSH PRAKASH
SINGH(25) KUMAR(39)

MRITYUNJAYA
VATSA(34)
INTRODUCTION 
• AJAX stands for Asynchronous JavaScript and Xml.

• Asynchronous means exchange data to/from the server in the


background without having to refresh page again and again.

• AJAX is not a programming language.


• AJAX is a technique for creating better , faster , and more
interactive web applications with the help of xml , html , CSS and
JavaScript.

• It provides a framework where JavaScript code can communicate


with the server in a simple and standard way.

• It also allows users to fetch data from the web server


asynchronously.
PROS AND CONS 
PROS

• Asynchronous calls

• Minimal data transfer

• Limited processing on the server

• Responsiveness
CONS

• Browser Incompatibility

• Insecurity

• Increased load on Web Server


SECURITY 
AJAX Security: Server Side

• AJAX-based Web applications use the same server-side


security schemes .

• Authentication, authorization, and data protection


requirements in our web.xml file.

• Same security threats as regular Web applications.


AJAX Security: Client Side

• JavaScript code is visible to a user/hacker.

• JavaScript code is downloaded from the


server and executed at the client.

• The sand-box security model


METHODS AND PROPERTIES 
TRANSACTION

• A typical AJAX Transaction looks like this:


1. User triggers some event
2. Event handler code sends HTTP request to server
3. Server replies triggering code on client
4. Reply handler code updates web page using server’s reply

• Event is asynchronous

• At no point during the transaction does the browser open a new


web page
SETTING UP AN AJAX TRANSACTION

• Create an XMLHttpRequest object

• Set up the request’s onreadystatechange function

• Open the request

• Send the request


METHODS

• abort()

• getAllResponseHeaders()

• open(method,url,asynchronous,user,password)

• send(content)

• setRequestHeader(header,value)
PROPERTIES

• onreadystatechange

• readyState

• responseText

• responseXml

• status
function sendRequest(){
var xmlHttp = new XMLHttpRequest();
if(!xmlHttp){
return false;
}
xmlHttp.onreadystatechange = function(){
if(xmlHttp.readyState==0){
alert("UNINITIALIZED");
}
if(xmlHttp.readyState==1){
alert("SERVER CONNECTION ESTABLISHED");
}
if(xmlHttp.readyState==2){
alert("REQUEST RECEIVED");
}
if(xmlHttp.readyState==3){
alert("PROCESSING REQUEST");
}
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
alert("REQUEST FINISHED");
alert(xmlHttp.status);
alert(xmlHttp.statusText);
document.getElementById("p2").innerHTML =
this.getResponseHeader('Content-Type');
document.getElementById("p3").innerHTML =this.getAllResponseHeaders();
myFunction(xmlHttp);
}
}
}
var requestURI = "ajaxxml.xml";
xmlHttp.open("GET",requestURI,true);
xmlHttp.send();
}
function myFunction(xml) {
var i;
var xmlDoc = xml.responseXML;
var table;

var x = xmlDoc.getElementsByTagName("user");
for (i = 0; i <x.length; i++) {
var users = x[i].firstChild.nodeValue;
var tr = document.createElement("tr");
var td = document.createElement("td");
var textNode = document.createTextNode(users);
td.appendChild(textNode);
tr.appendChild(td);
document.getElementById("area").appendChild(tr);
}
} RUN
TEXT FILE:-

<script>
function loadDoc()
{
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function checking()
{
if(this.readyState==4 && this.status==200)
{

document.getElementById("demo").innerHTML
=this.responseText;
}
}
xhttp.open("GET","ajaxinfo.txt",true);
xhttp.send();
}
</script>
<body>
<div id="demo">
<h3>AJAX EXAMPLE</h3>
<button type="button" onclick="loadDoc()">Change Content</button>
</div>

<div>
This div will not be sent to the server.
</div>
</body>
</html>

Try this code


AJAX cannot work independently. It is used
in combination with other technologies to
create interactive WebPages.
 Google Maps
A user can drag an entire map by using the mouse,
rather than clicking on a button.

 Google Suggest
As you type, Google offers suggestions. Use the
arrow keys to navigate the results.

 Gmail
Gmail is a webmail built on the idea that emails can
be more intuitive, efficient, and useful.
Example ….

Вам также может понравиться