Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Ajax Tutorial Full Course Beginnes and Advanced level

Ajax Tutorial



v  Asynchronous JavaScript  and  xml
v  Browser sends and receives  data in the background
v  Group of technologies ,not a single technology(javascript,xml,json,html,css,php)
History of Ajax:
·         1999:microsoft’s internet explorer 5 adds xmlhttp active control
·         2000-2002:mozila creates standardized xmlhttprequest modeled on  microsoft’s interface
·         2002-2006:xmlhttprequest is adopted by all web browsers
·         2004:Goole  uses xmlhttprequest for gmailàuse gmail account first
·         2004:google user xmlhtprequest for Google suggest -àserarch engines
·         2005:google uses uses xmlrequest for google maps
·         2004-2005:other sites begin using xmlhttprequestàammazaon,flipcart,google
·         “Ajax:A new approach to web application”, Jess JamesGarrett ,Adaptive path feb 18 2005
·         http:adaptive.rg/ideas/ajax-new-apporach-web-applications/

Classic HTTP Model:
Ø  use performs an action(eg,clicking a link)
Ø  HTTP Request sent to the server
Ø  Server processes request
Ø  Server returns HTML  browser
Ø  Users must  wait for server response

Ajax Model
Ø  Webpages loads javascript (“Ajax Engine”)
Ø  User performs an action (eg.clicking a link”)
Ø  Request guest to javascript first,not server
Ø  Javascript may handle the request directly
Ø  Validate data,upadate navigation,edit internal values
Ø  Javascript can communicate with the server in the background
Ø  Its sends xml asynchronously using xmlhttprequest
Ø  Response data  can be used to update the page
Ø  User can continue interaction with page ,with no waiting

Ajax Components
Ø  HTML,CSS,and document object model
Ø  Xml
Ø  Xmlhttprequest
Ø  Javavascript

Ajax Responses

v  ResoResponsess can either be text or XML
v  responseText
v  responseXML
v  Text is more flexible:text,HTML,JSON,image,etc
Exmple request code:
Var xhr=new XMLHttpRequsest();
Xhr.open(“GET”,”script.php”,true);
Xhr.send();
Var  text=xhr.responseText;
Var target=document.getElementById(“main”);
Target.innerHTML=text;
Parse the Response
XML
JSON
Javascript and JSON Datatypes:
Var person={
‘fisr_name’:’Bob’,
‘last_name’:’smith’

},
Var response=”{
‘first_name’:bob’’,
‘last_name’:’smith’
}”;
Var person=JSON.parse(reponse);

Ready States:

v  0:connection created but not opened
v  1:Connection opened
v  Request sent,received by server
v  Response in progress(partial data)
v  Response complete (success or failure)

Ready State Change

ü  onreadystatechange
ü  Used to store a javascript functiom
ü  Called each time readystate changes
ü  Prevents having to constantly recheck value



Onreadystayechange function:
Var xhr= new XMLHttpRequest();
Xhr.open(“GET”,”script.php”,true);
Xhr.onreadystatechange=function(){
If(xhr.readyState==4&&xhr.status==200){
Var target=document.getElementById(“main”);
Target.innerHTML=xhr.responseTexe;
}}

Share the post

Ajax Tutorial Full Course Beginnes and Advanced level

×

Subscribe to Webdesign | Seo Services Full Tutorial | Php Full Tutorial | Javascript Full Tutorial|html,css,cms

Get updates delivered right to your inbox!

Thank you for your subscription

×