SlideShare ist ein Scribd-Unternehmen logo
1 von 20
What is AJAX ?
• Asynchronous Javascript and XML.
• Not a stand-alone language or technology.
• It is a technique that combines a set of
known technologies in order to create faster
and more user friendly web pages.
• It is a client side technology.
Purpose of AJAX
• Prevents unnecessary reloading of a page.
• When we submit a form, although most of the
page remains the same, whole page is reloaded
from the server.
• This causes very long waiting times and waste of
bandwidth.
• AJAX aims at loading only the necessary
innformation, and making only the necessary
changes on the current page without reloading the
whole page.
Technologies Used
• AJAX uses:
– Javascript (for altering the page)
– XML (for information exchange)
– ASP or JSP (server side)
Simple Processing
• AJAX is based on Javascript, and the main
functionality is to access the web server inside the
Javascript code.
• We access to the server using special objects; we
send data and retrieve data.
• When user initiates an event, a javascript function
is called which accesses server using the objects.
• The received information is shown to the user by
means of the Javascript’s functions.
Example
• We want to input data into a textbox.
• We want the textbox to have intellisense
property; guess entries according to input.
• http://www.w3schools.com/ajax/ajax_example.asp
• Only the ‘span’ part of the html code is changed.
Data Exchange in AJAX
• In AJAX:
Example(2)
• Another example:
http://www.w3schools.com/ajax/ajax_database.asp
• Therefore, by using AJAX, unnecessary
exchange of data is prevented, web pages
become:
– More interactive
– Faster
– More user friendly
History of AJAX
• Starts with web pages
• Static web pages
– Static html page is loaded
– No interaction with user
• Dynamic web pages
– Html page is generated dynamically
– Interaction with user
– Becomes slower as functionality increases
– Speed becomes untolerable, so AJAX has been
born
Alternative Technologies
• Not a technology, but a combination of
technologies.
• Technologies with similar tasks:
URLConnection, ASP and JSP
• Other technologies returns whole page and
client loads it.
• Only necessary data is returned and that
part is updated
Structure of System
• Client/Server architecture
• XMLHTTP object is used to make request
and get response in Client side
• Request can be done via “GET” or “POST”
methods
– “GET”: parameters are attached to the url used
to connect.
– “POST”: parameters are sent as parameters to a
function
• Not many changes in Server side
– Response is a combination of xml tags
C/S Processes
• Most of the time client requires two files
– Html page: handles GUI and calls a function of
JavaScript.
– JavaScript: handles the business logic of the
system
• In JavaScript, a request is sent to client and
response is taken from server via XMLHTTP
object
• Response of server should be returned in xml
file structure
Examination of Sample
• General process will be explained on an
example at http://www.w3schools.com/ajax/ajax_database.asp.
• In this example, one html page and one
JavaSocket reside in Client side of the
system while an ASP page resides in Server
sides.
Html Code of Example
<html><head>
<script src="selectcustomer.js">
</script></head><body>
<form> Select a Customer:
<select name="customers" onchange="showCustomer(this.value)">
<option value="ALFKI">Alfreds Futterkiste
<option value="NORTS ">North/South
<option value="WOLZA">Wolski Zajazd
</select></form><p>
<div id="txtHint"><b>Customer info will be listed here.</b></div>
</p></body></html>
JavaScript of Example
function showCustomer(str) {
var url="getcustomer.asp?sid=" + Math.random() + "&q=" + str
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}
function stateChanged() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById("txtHint").innerHTML = 
xmlHttp.responseText
}
}
ASP Code of Example
sql="SELECT * FROM CUSTOMERS WHERE CUSTOMERID="
sql=sql & request.querystring("q")
............ Open Connection to the DB
rs.Open sql, conn
response.write("<table>")
do until rs.EOF
for each x in rs.Fields
response.write("<tr><td><b>" & x.name & "</b></td>")
response.write("<td> & x.value & "</td></tr>")
next
rs.MoveNext
loop
response.write("</table>")
XMLHTTP Object
• The object that is used to connect to the
remote server is called XMLHTTP.
• It resembles the Java’s URL object that is
used to access a specific URL and get the
contents.
Creating the object
• For IE 5.5:
objXmlHttp=new ActiveXObject(“Microsoft.XMLHTTP”)
• For Mozilla:
objXmlHttp=new XMLHttpRequest()
Sending information
• After creating the object, we can send information to the
web server and get the answer using this object’s
functions:
• GET METHOD: xmlhttp.open(“GET”, url, true)
xmlhttp.send()
• POST METHOD: xmlhttp.open("POST", url, true)
xmlhttp.send(“date=11-11-2006&name=Ali")
• Third argument tells that data will be processes asynchronously. When
server responds, the “OnReadyStateChange” event handler will be
called.
Retrieving information
• We get the returned value with the property
“xmlHttp.responseText”.
Pros/Cons
• Advantages:
– Independent of server technology.
– Apart from obtaining the XMLHTTP object, all processing is same
for all browser types, because Javascript is used.
– Permits the development of faster and more interactive web
applications.
• Disadvantages:
– The back button problem. People think that when they press back
button, they will return to the last change they made, but in AJAX
this doesn not hold.
– Possible network latency problems. People should be given
feedback about the processing.
– Does not run on all browsers.

Weitere ähnliche Inhalte

Was ist angesagt?

Ajax Introduction Presentation
Ajax   Introduction   PresentationAjax   Introduction   Presentation
Ajax Introduction Presentation
thinkphp
 
An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programming
hchen1
 

Was ist angesagt? (20)

Ajax
AjaxAjax
Ajax
 
PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
 
Ajax and PHP
Ajax and PHPAjax and PHP
Ajax and PHP
 
Ajax Presentation
Ajax PresentationAjax Presentation
Ajax Presentation
 
Introduction to ajax
Introduction  to  ajaxIntroduction  to  ajax
Introduction to ajax
 
Ajax
AjaxAjax
Ajax
 
Overview of AJAX
Overview of AJAXOverview of AJAX
Overview of AJAX
 
Ajax Technology
Ajax TechnologyAjax Technology
Ajax Technology
 
Ajax
Ajax Ajax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Jquery Ajax
Jquery AjaxJquery Ajax
Jquery Ajax
 
Ajax Introduction Presentation
Ajax   Introduction   PresentationAjax   Introduction   Presentation
Ajax Introduction Presentation
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Ajax Ppt
Ajax PptAjax Ppt
Ajax Ppt
 
Ajax Presentation
Ajax PresentationAjax Presentation
Ajax Presentation
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programming
 
Ajax
AjaxAjax
Ajax
 
Ajax presentation
Ajax presentationAjax presentation
Ajax presentation
 

Andere mochten auch (11)

Top mba colleges in east delhi
Top mba colleges in east delhiTop mba colleges in east delhi
Top mba colleges in east delhi
 
Presentation on waste water diffuser
Presentation on waste water diffuserPresentation on waste water diffuser
Presentation on waste water diffuser
 
Deepshikha html
Deepshikha htmlDeepshikha html
Deepshikha html
 
Arts colleges in bihar
Arts colleges in biharArts colleges in bihar
Arts colleges in bihar
 
Presentation on candle filter bag
Presentation on candle filter bagPresentation on candle filter bag
Presentation on candle filter bag
 
Presentation on spun bonded filter cartridge
Presentation on spun bonded filter cartridgePresentation on spun bonded filter cartridge
Presentation on spun bonded filter cartridge
 
Presentation on fabric
Presentation on fabricPresentation on fabric
Presentation on fabric
 
Presentation on FBD filter bags
Presentation on FBD filter bagsPresentation on FBD filter bags
Presentation on FBD filter bags
 
Presentation on solenoid valve
Presentation on solenoid valvePresentation on solenoid valve
Presentation on solenoid valve
 
Presentation on geotextile
Presentation on geotextilePresentation on geotextile
Presentation on geotextile
 
Presentation 2
Presentation 2Presentation 2
Presentation 2
 

Ähnlich wie Ajax

Ähnlich wie Ajax (20)

Ajax tutorial by bally chohan
Ajax tutorial by bally chohanAjax tutorial by bally chohan
Ajax tutorial by bally chohan
 
Ajax
AjaxAjax
Ajax
 
Unit-5.pptx
Unit-5.pptxUnit-5.pptx
Unit-5.pptx
 
AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Ajax Introduction
Ajax IntroductionAjax Introduction
Ajax Introduction
 
Ajax
AjaxAjax
Ajax
 
Ajax
Ajax Ajax
Ajax
 
AJAX
AJAXAJAX
AJAX
 
Ajax Tuturial
Ajax TuturialAjax Tuturial
Ajax Tuturial
 
WEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptxWEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptx
 
Ajax
AjaxAjax
Ajax
 
Core Java tutorial at Unit Nexus
Core Java tutorial at Unit NexusCore Java tutorial at Unit Nexus
Core Java tutorial at Unit Nexus
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Synapseindia dot net development web applications with ajax
Synapseindia dot net development  web applications with ajaxSynapseindia dot net development  web applications with ajax
Synapseindia dot net development web applications with ajax
 
Ajax
AjaxAjax
Ajax
 
M Ramya
M RamyaM Ramya
M Ramya
 
Ajax
AjaxAjax
Ajax
 

Mehr von Siya Agarwal

Mehr von Siya Agarwal (20)

Whats digital marketing
Whats digital marketingWhats digital marketing
Whats digital marketing
 
amrapali la residentia
amrapali la residentiaamrapali la residentia
amrapali la residentia
 
Anode filter bags
Anode filter bagsAnode filter bags
Anode filter bags
 
Pmp west delhi
Pmp west delhiPmp west delhi
Pmp west delhi
 
Solar home lighting system
Solar home lighting systemSolar home lighting system
Solar home lighting system
 
Solar off grid
Solar off gridSolar off grid
Solar off grid
 
Solar charge controller
Solar charge controllerSolar charge controller
Solar charge controller
 
Presentation on venturi
Presentation on venturiPresentation on venturi
Presentation on venturi
 
Presentation on sparkler filter bag
Presentation on sparkler filter bagPresentation on sparkler filter bag
Presentation on sparkler filter bag
 
Presentation on screening mesh
Presentation on screening meshPresentation on screening mesh
Presentation on screening mesh
 
Presentation on reverse air type filter bag
Presentation on reverse air type filter bagPresentation on reverse air type filter bag
Presentation on reverse air type filter bag
 
Presentation on pulveriser sleeve
Presentation on pulveriser sleevePresentation on pulveriser sleeve
Presentation on pulveriser sleeve
 
Presentation on pp cartridge housing filter
Presentation on pp cartridge housing filterPresentation on pp cartridge housing filter
Presentation on pp cartridge housing filter
 
Presentation on nutsche filter bag
Presentation on nutsche filter bagPresentation on nutsche filter bag
Presentation on nutsche filter bag
 
Presentation on fine bubble diffuser
Presentation on fine bubble diffuserPresentation on fine bubble diffuser
Presentation on fine bubble diffuser
 
Presentation on support cages
Presentation on support cagesPresentation on support cages
Presentation on support cages
 
Presentation on printing mesh
Presentation on printing meshPresentation on printing mesh
Presentation on printing mesh
 
Presentation on hvac pre filtration
Presentation on hvac pre filtrationPresentation on hvac pre filtration
Presentation on hvac pre filtration
 
Presentation on random growth media
Presentation on random growth mediaPresentation on random growth media
Presentation on random growth media
 
Presentation on filter press panels
Presentation on filter press panelsPresentation on filter press panels
Presentation on filter press panels
 

Ajax

  • 1. What is AJAX ? • Asynchronous Javascript and XML. • Not a stand-alone language or technology. • It is a technique that combines a set of known technologies in order to create faster and more user friendly web pages. • It is a client side technology.
  • 2. Purpose of AJAX • Prevents unnecessary reloading of a page. • When we submit a form, although most of the page remains the same, whole page is reloaded from the server. • This causes very long waiting times and waste of bandwidth. • AJAX aims at loading only the necessary innformation, and making only the necessary changes on the current page without reloading the whole page.
  • 3. Technologies Used • AJAX uses: – Javascript (for altering the page) – XML (for information exchange) – ASP or JSP (server side)
  • 4. Simple Processing • AJAX is based on Javascript, and the main functionality is to access the web server inside the Javascript code. • We access to the server using special objects; we send data and retrieve data. • When user initiates an event, a javascript function is called which accesses server using the objects. • The received information is shown to the user by means of the Javascript’s functions.
  • 5. Example • We want to input data into a textbox. • We want the textbox to have intellisense property; guess entries according to input. • http://www.w3schools.com/ajax/ajax_example.asp • Only the ‘span’ part of the html code is changed.
  • 6. Data Exchange in AJAX • In AJAX:
  • 7. Example(2) • Another example: http://www.w3schools.com/ajax/ajax_database.asp • Therefore, by using AJAX, unnecessary exchange of data is prevented, web pages become: – More interactive – Faster – More user friendly
  • 8. History of AJAX • Starts with web pages • Static web pages – Static html page is loaded – No interaction with user • Dynamic web pages – Html page is generated dynamically – Interaction with user – Becomes slower as functionality increases – Speed becomes untolerable, so AJAX has been born
  • 9. Alternative Technologies • Not a technology, but a combination of technologies. • Technologies with similar tasks: URLConnection, ASP and JSP • Other technologies returns whole page and client loads it. • Only necessary data is returned and that part is updated
  • 10. Structure of System • Client/Server architecture • XMLHTTP object is used to make request and get response in Client side • Request can be done via “GET” or “POST” methods – “GET”: parameters are attached to the url used to connect. – “POST”: parameters are sent as parameters to a function • Not many changes in Server side – Response is a combination of xml tags
  • 11. C/S Processes • Most of the time client requires two files – Html page: handles GUI and calls a function of JavaScript. – JavaScript: handles the business logic of the system • In JavaScript, a request is sent to client and response is taken from server via XMLHTTP object • Response of server should be returned in xml file structure
  • 12. Examination of Sample • General process will be explained on an example at http://www.w3schools.com/ajax/ajax_database.asp. • In this example, one html page and one JavaSocket reside in Client side of the system while an ASP page resides in Server sides.
  • 13. Html Code of Example <html><head> <script src="selectcustomer.js"> </script></head><body> <form> Select a Customer: <select name="customers" onchange="showCustomer(this.value)"> <option value="ALFKI">Alfreds Futterkiste <option value="NORTS ">North/South <option value="WOLZA">Wolski Zajazd </select></form><p> <div id="txtHint"><b>Customer info will be listed here.</b></div> </p></body></html>
  • 14. JavaScript of Example function showCustomer(str) { var url="getcustomer.asp?sid=" + Math.random() + "&q=" + str xmlHttp=GetXmlHttpObject(stateChanged) xmlHttp.open("GET", url , true) xmlHttp.send(null) } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ document.getElementById("txtHint").innerHTML = xmlHttp.responseText } }
  • 15. ASP Code of Example sql="SELECT * FROM CUSTOMERS WHERE CUSTOMERID=" sql=sql & request.querystring("q") ............ Open Connection to the DB rs.Open sql, conn response.write("<table>") do until rs.EOF for each x in rs.Fields response.write("<tr><td><b>" & x.name & "</b></td>") response.write("<td> & x.value & "</td></tr>") next rs.MoveNext loop response.write("</table>")
  • 16. XMLHTTP Object • The object that is used to connect to the remote server is called XMLHTTP. • It resembles the Java’s URL object that is used to access a specific URL and get the contents.
  • 17. Creating the object • For IE 5.5: objXmlHttp=new ActiveXObject(“Microsoft.XMLHTTP”) • For Mozilla: objXmlHttp=new XMLHttpRequest()
  • 18. Sending information • After creating the object, we can send information to the web server and get the answer using this object’s functions: • GET METHOD: xmlhttp.open(“GET”, url, true) xmlhttp.send() • POST METHOD: xmlhttp.open("POST", url, true) xmlhttp.send(“date=11-11-2006&name=Ali") • Third argument tells that data will be processes asynchronously. When server responds, the “OnReadyStateChange” event handler will be called.
  • 19. Retrieving information • We get the returned value with the property “xmlHttp.responseText”.
  • 20. Pros/Cons • Advantages: – Independent of server technology. – Apart from obtaining the XMLHTTP object, all processing is same for all browser types, because Javascript is used. – Permits the development of faster and more interactive web applications. • Disadvantages: – The back button problem. People think that when they press back button, they will return to the last change they made, but in AJAX this doesn not hold. – Possible network latency problems. People should be given feedback about the processing. – Does not run on all browsers.