SlideShare a Scribd company logo
1 of 24
Download to read offline
Building
Applications
using AJAX

WebOSS ‘07
S Pradeep
What is AJAX?
 AJAX = Asynchronous JavaScript And XML
 Is a web development technique used for
 creating faster, interactive web applications.
Who uses AJAX?
 Google maps
 Gmail
 Google Suggest
 Flickr
 del.icio.us
 Meebo
 and many more…
How AJAX is different
Need for AJAX
 To increase web's interactivity, speed and
 usability
 Issues with classic web applications
 * Almost all processing is done on server
 * High latency
 * Low interactivity
Benefits of Using AJAX
 Enhance your sites by allowing quicker
 access to data.
 Reduce the amount of bandwidth used in
 data presentation.
 Make a web application that feels more like
 a native application.
AJAX Workarounds
 Hidden IFRAME
 <SCRIPT> src hack
 Cookies
Where to use AJAX
 Anywhere you have a search box, adding
 Google suggest functionality.
 Pages where you have a multi-step process.
 When working with large or highly
 interdependent datasets.
Simple Ajax Application : How To
 Create a request object
 Make the request
 Handle the response
Create a request object
if browser is mozilla or safari or opera then
   create a new XMLHttpRequest
otherwise if browser is IE
   create a new ActiveXObject
otherwise
   error - browser does not support XMLHttpRequest


  IE 5,5.5,6 implement XHR as an ActiveX
  object
  (Msxml2.XMLHTTP/Microsoft.XMLHTTP)
  Mozilla 1.0+, Safari 1.2+, Opera 8+, IE7
  provide XMLHttpRequest natively.
  All XHR objects have the same methods and
  properties.
Code
var xhr = null;
if(window.XMLHttpRequest) // Mozilla,Safari, etc.
{
  xhr = new XMLHttpRequest();
}
else if(window.ActiveXObject) // < IE 7
{
  xhr = new ActiveXObject('Microsoft.XMLHTTP');
}
Else
{
  alert('Oops! Your browser does not support
  XMLHttpRequest');
}
XHR Methods
 open(‘method’,’url’,asyncFlag)
 send(content)
 abort()
 getResponseHeader(“header”)
 setRequestHeader(“header”,”value”)
XHR properties
 onreadystatechange
 readystate
 responseText
 responseXML
 status
 statusText
Make the request
 set onreadystatechange to callback function
 cbProcessResponse
 open a request on the XHR object
 send the request through the XHR object
 “Same Site” rule
 “GET” or “POST”
 Asynchronous flag
Code
xhr.onreadystatechange=cbProcessResponse;
xhr.open(’GET’,‘ajax.php’,true);

function cbProcessResponse()
{
   if(xhr.readystate==4 && xhr.status==200)
   {
       alert(xhr.responseText);
   }
}

/* readystate values
0 -> uninitialized
1 -> loading
2 -> loaded
3 -> interactive
4 -> completed
*/
Handle Response: Parsing the XML
// Our sample XML
<?xml version=quot;1.0quot; encoding=quot;ISO-8859-1quot;?>
<root>
   <response>OK</response>
   <msg>Hello World!</msg>
</root>

// Revised callback function
function cbProcessResponse()
{
   if(xhr.readystate==4 && xhr.status==200)
   {
     var xmlDoc = xhr.responseXML.documentElement;
     var s = x.getElementsByTagName('response')[0].firstChild.data;
     var m = x.getElementsByTagName('msg')[0].firstChild.data;
     alert(‘Response Code:’+s+’nMessage: ‘+m)
   }
}
Enter JSON
  JavaScript Object Notation
  JSON is a lightweight data-interchange format.
  JSON data are slightly simpler and slightly more in
  line with the rest of the JavaScript language than
  scripts for XML data.
  Find more about JSON at http://json.org

//sample JSON
{
   response: ‘OK’,
   msg: ‘Hello World’
}
JSON How?
  JSON can be generated by all the popular server-side languages.
  Native/Library Support

// Revised callback function to use JSON
function cbProcessResponse()
{
  if(xhr.readystate==4 && xhr.status==200)
  {
    var jsonData = eval(‘(‘+xhr.responseText+’)’);
    var s = jsonData.response; // easy ;-)
    var m = jsonData.msg;
    alert(‘Response Code:’+s+’nMessage: ‘+m)
  }
}

  Doesn’t that look simpler?
Frameworks
 A framework is a re-usable design for a
 software system with built-in generic
 functions for performing repetitive, natively
 unsupported operations.
 The Prototype JavaScript Framework is
 a JavaScript framework that provides an
 Ajax framework and other utilities.
 Download from http://prototypejs.org
 Others: YUI, Dojo, jQuery, mooTools
Using Prototype.js
  Prototype provides the Ajax object to abstract the
  different browsers.
  Ajax.Request()
  Ajax.Updater(container, url[, options])
var pars = 'topic=ajax&framework=pjs';
Var url = '/cgi-bin/myAjaxHandler.cgi';
var myAjax = new Ajax.Request(url,{
        method: quot;postquot;, // get/post
        parameters: pars,
        onComplete: cbProcessResponse // Our old callback
   function
        });


  Ajax.PeriodicalUpdater(container, url[, options])
Tips
 Don't overuse AJAX, the usability
 requirements for JavaScript applications are
 quite different than the requirements for
 regular web pages.
 Escape content sent to the server.
 Use AJAX activity indicators.
 http://www.napyfab.com/ajax-indicators/
Debugging AJAX
 Always test your PHP/Server-side code
 before integrating it with the JavaScript
 side.
 Always check xhr.status
 Use FireBug to pin-point errors, and trace
 performance bottle-necks.
 Download from http://www.getfirebug.com/
Resources
 AJAXIAN - http://ajaxian.com
 AJAX info - http://ajaxinfo.com
 AJAX Lesson - http://ajaxlessons.com
 Go4Expert - http://go4expert.com
Thanks!
 Hussain Fakhruddin
 Teknowledge Software




 The wonderful audience.

More Related Content

What's hot

Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsTessa Mero
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsNeil Crookes
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswanivvaswani
 
Request dispacther interface ppt
Request dispacther interface pptRequest dispacther interface ppt
Request dispacther interface pptTaha Malampatti
 
What is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaWhat is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaEdureka!
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flaskJim Yeh
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPressTaylor Lovett
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHPZoran Jeremic
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web APIhabib_786
 
React with WordPress : Headless CMS
React with WordPress : Headless CMSReact with WordPress : Headless CMS
React with WordPress : Headless CMSImran Sayed
 
The Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReSTThe Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReSTBruno Kessler Foundation
 
PHP And Web Services: Perfect Partners
PHP And Web Services: Perfect PartnersPHP And Web Services: Perfect Partners
PHP And Web Services: Perfect PartnersLorna Mitchell
 
Build Modern Web Applications with React and WordPress
Build Modern Web Applications with React and WordPressBuild Modern Web Applications with React and WordPress
Build Modern Web Applications with React and WordPressImran Sayed
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 

What's hot (20)

Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple Steps
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIs
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
 
Request dispacther interface ppt
Request dispacther interface pptRequest dispacther interface ppt
Request dispacther interface ppt
 
What is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaWhat is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | Edureka
 
CakePHP REST Plugin
CakePHP REST PluginCakePHP REST Plugin
CakePHP REST Plugin
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flask
 
Node js crash course session 3
Node js crash course   session 3Node js crash course   session 3
Node js crash course session 3
 
Develop webservice in PHP
Develop webservice in PHPDevelop webservice in PHP
Develop webservice in PHP
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPress
 
Wt unit 5
Wt unit 5Wt unit 5
Wt unit 5
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
 
React with WordPress : Headless CMS
React with WordPress : Headless CMSReact with WordPress : Headless CMS
React with WordPress : Headless CMS
 
ASP.NET WEB API Training
ASP.NET WEB API TrainingASP.NET WEB API Training
ASP.NET WEB API Training
 
The Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReSTThe Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReST
 
Node js crash course session 2
Node js crash course   session 2Node js crash course   session 2
Node js crash course session 2
 
PHP And Web Services: Perfect Partners
PHP And Web Services: Perfect PartnersPHP And Web Services: Perfect Partners
PHP And Web Services: Perfect Partners
 
Build Modern Web Applications with React and WordPress
Build Modern Web Applications with React and WordPressBuild Modern Web Applications with React and WordPress
Build Modern Web Applications with React and WordPress
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 

Viewers also liked

Ajax Introduction Presentation
Ajax   Introduction   PresentationAjax   Introduction   Presentation
Ajax Introduction Presentationthinkphp
 
An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programminghchen1
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajaxNir Elbaz
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slidesSmithss25
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajaxRaja V
 
Intro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETIntro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETAlan Hecht
 
WebApp / SPA @ AllFacebook Developer Conference
WebApp / SPA @ AllFacebook Developer ConferenceWebApp / SPA @ AllFacebook Developer Conference
WebApp / SPA @ AllFacebook Developer ConferenceAllFacebook.de
 
Writing SPA in 2017
Writing SPA in 2017Writing SPA in 2017
Writing SPA in 2017Arek Flinik
 
Webinar on Angular JS titled 'Develop Responsive Single Page Application'
Webinar on Angular JS titled 'Develop Responsive Single Page Application'Webinar on Angular JS titled 'Develop Responsive Single Page Application'
Webinar on Angular JS titled 'Develop Responsive Single Page Application'Edureka!
 
Single page application
Single page applicationSingle page application
Single page applicationJeremy Lee
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentationJohn Staveley
 
SPA 2009 - Acceptance Testing AJAX Web Applications through the GUI
SPA 2009 - Acceptance Testing AJAX Web Applications through the GUISPA 2009 - Acceptance Testing AJAX Web Applications through the GUI
SPA 2009 - Acceptance Testing AJAX Web Applications through the GUIandrew.macleod
 

Viewers also liked (18)

Jsf Ajax
Jsf AjaxJsf Ajax
Jsf Ajax
 
Ajax presentation
Ajax presentationAjax presentation
Ajax presentation
 
Ajax Introduction Presentation
Ajax   Introduction   PresentationAjax   Introduction   Presentation
Ajax Introduction Presentation
 
An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programming
 
Ajax Ppt
Ajax PptAjax Ppt
Ajax Ppt
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slides
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Ajax.ppt
Ajax.pptAjax.ppt
Ajax.ppt
 
Intro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETIntro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NET
 
WebApp / SPA @ AllFacebook Developer Conference
WebApp / SPA @ AllFacebook Developer ConferenceWebApp / SPA @ AllFacebook Developer Conference
WebApp / SPA @ AllFacebook Developer Conference
 
Writing SPA in 2017
Writing SPA in 2017Writing SPA in 2017
Writing SPA in 2017
 
Webinar on Angular JS titled 'Develop Responsive Single Page Application'
Webinar on Angular JS titled 'Develop Responsive Single Page Application'Webinar on Angular JS titled 'Develop Responsive Single Page Application'
Webinar on Angular JS titled 'Develop Responsive Single Page Application'
 
Single page application
Single page applicationSingle page application
Single page application
 
Single page application
Single page applicationSingle page application
Single page application
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentation
 
Ajax Ppt 1
Ajax Ppt 1Ajax Ppt 1
Ajax Ppt 1
 
SPA 2009 - Acceptance Testing AJAX Web Applications through the GUI
SPA 2009 - Acceptance Testing AJAX Web Applications through the GUISPA 2009 - Acceptance Testing AJAX Web Applications through the GUI
SPA 2009 - Acceptance Testing AJAX Web Applications through the GUI
 

Similar to Building Web Applications using AJAX

Similar to Building Web Applications using AJAX (20)

mukesh
mukeshmukesh
mukesh
 
Ajax
AjaxAjax
Ajax
 
How to make Ajax work for you
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for you
 
Ajax tutorial
Ajax tutorialAjax tutorial
Ajax tutorial
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Ajax Lecture Notes
Ajax Lecture NotesAjax Lecture Notes
Ajax Lecture Notes
 
Ajax3
Ajax3Ajax3
Ajax3
 
Ajax for dummies, and not only.
Ajax for dummies, and not only.Ajax for dummies, and not only.
Ajax for dummies, and not only.
 
Pracitcal AJAX
Pracitcal AJAXPracitcal AJAX
Pracitcal AJAX
 
Ajax
AjaxAjax
Ajax
 
Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)
 
Ajax Introduction
Ajax IntroductionAjax Introduction
Ajax Introduction
 
Ajax Fundamentals Web Applications
Ajax Fundamentals Web ApplicationsAjax Fundamentals Web Applications
Ajax Fundamentals Web Applications
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
 
Beyond HTML: Tools for Building Web 2.0 Apps
Beyond HTML: Tools for Building Web 2.0 AppsBeyond HTML: Tools for Building Web 2.0 Apps
Beyond HTML: Tools for Building Web 2.0 Apps
 
Ajax - a quick introduction
Ajax - a quick introductionAjax - a quick introduction
Ajax - a quick introduction
 
Ajax
AjaxAjax
Ajax
 
Ajax tutorial by bally chohan
Ajax tutorial by bally chohanAjax tutorial by bally chohan
Ajax tutorial by bally chohan
 
Ajax
AjaxAjax
Ajax
 

More from s_pradeep

Aish Pink Panther
Aish Pink PantherAish Pink Panther
Aish Pink Panthers_pradeep
 
Bhool Bhulaiya
Bhool BhulaiyaBhool Bhulaiya
Bhool Bhulaiyas_pradeep
 
T20 World Cup Final Photos
T20 World Cup Final PhotosT20 World Cup Final Photos
T20 World Cup Final Photoss_pradeep
 
Football Strategies
Football StrategiesFootball Strategies
Football Strategiess_pradeep
 
Amby Valley City
Amby Valley CityAmby Valley City
Amby Valley Citys_pradeep
 
Parvathi Melton
Parvathi MeltonParvathi Melton
Parvathi Meltons_pradeep
 
Abhishek and Aishwarya At IIFA 2007
Abhishek and Aishwarya At IIFA 2007Abhishek and Aishwarya At IIFA 2007
Abhishek and Aishwarya At IIFA 2007s_pradeep
 
IIFA 2007 Awards
IIFA 2007 AwardsIIFA 2007 Awards
IIFA 2007 Awardss_pradeep
 
Maria Sharapova
Maria SharapovaMaria Sharapova
Maria Sharapovas_pradeep
 
Golden Smile - Perizaad Zorabian
Golden Smile - Perizaad ZorabianGolden Smile - Perizaad Zorabian
Golden Smile - Perizaad Zorabians_pradeep
 
South Indian Actress Poonam Bajwa
South Indian Actress Poonam BajwaSouth Indian Actress Poonam Bajwa
South Indian Actress Poonam Bajwas_pradeep
 
Trisha In Bheema
Trisha In BheemaTrisha In Bheema
Trisha In Bheemas_pradeep
 
Aishwarya At French Open 2007
Aishwarya At French Open 2007Aishwarya At French Open 2007
Aishwarya At French Open 2007s_pradeep
 
Bollywood Beauties
Bollywood BeautiesBollywood Beauties
Bollywood Beautiess_pradeep
 
Vinod Kambli's Wife
Vinod Kambli's WifeVinod Kambli's Wife
Vinod Kambli's Wifes_pradeep
 
Miss Universe 2007 Bikini Round
Miss Universe 2007 Bikini RoundMiss Universe 2007 Bikini Round
Miss Universe 2007 Bikini Rounds_pradeep
 
Peek Into Bollywood
Peek Into BollywoodPeek Into Bollywood
Peek Into Bollywoods_pradeep
 
Bollywood Babes
Bollywood BabesBollywood Babes
Bollywood Babess_pradeep
 

More from s_pradeep (20)

Aish Pink Panther
Aish Pink PantherAish Pink Panther
Aish Pink Panther
 
Shriya
ShriyaShriya
Shriya
 
Bhool Bhulaiya
Bhool BhulaiyaBhool Bhulaiya
Bhool Bhulaiya
 
T20 World Cup Final Photos
T20 World Cup Final PhotosT20 World Cup Final Photos
T20 World Cup Final Photos
 
Football Strategies
Football StrategiesFootball Strategies
Football Strategies
 
Amby Valley City
Amby Valley CityAmby Valley City
Amby Valley City
 
Parvathi Melton
Parvathi MeltonParvathi Melton
Parvathi Melton
 
Abhishek and Aishwarya At IIFA 2007
Abhishek and Aishwarya At IIFA 2007Abhishek and Aishwarya At IIFA 2007
Abhishek and Aishwarya At IIFA 2007
 
IIFA 2007 Awards
IIFA 2007 AwardsIIFA 2007 Awards
IIFA 2007 Awards
 
Maria Sharapova
Maria SharapovaMaria Sharapova
Maria Sharapova
 
Golden Smile - Perizaad Zorabian
Golden Smile - Perizaad ZorabianGolden Smile - Perizaad Zorabian
Golden Smile - Perizaad Zorabian
 
South Indian Actress Poonam Bajwa
South Indian Actress Poonam BajwaSouth Indian Actress Poonam Bajwa
South Indian Actress Poonam Bajwa
 
Trisha In Bheema
Trisha In BheemaTrisha In Bheema
Trisha In Bheema
 
Nayanthara
NayantharaNayanthara
Nayanthara
 
Aishwarya At French Open 2007
Aishwarya At French Open 2007Aishwarya At French Open 2007
Aishwarya At French Open 2007
 
Bollywood Beauties
Bollywood BeautiesBollywood Beauties
Bollywood Beauties
 
Vinod Kambli's Wife
Vinod Kambli's WifeVinod Kambli's Wife
Vinod Kambli's Wife
 
Miss Universe 2007 Bikini Round
Miss Universe 2007 Bikini RoundMiss Universe 2007 Bikini Round
Miss Universe 2007 Bikini Round
 
Peek Into Bollywood
Peek Into BollywoodPeek Into Bollywood
Peek Into Bollywood
 
Bollywood Babes
Bollywood BabesBollywood Babes
Bollywood Babes
 

Recently uploaded

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Recently uploaded (20)

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Building Web Applications using AJAX

  • 2. What is AJAX? AJAX = Asynchronous JavaScript And XML Is a web development technique used for creating faster, interactive web applications.
  • 3. Who uses AJAX? Google maps Gmail Google Suggest Flickr del.icio.us Meebo and many more…
  • 4. How AJAX is different
  • 5. Need for AJAX To increase web's interactivity, speed and usability Issues with classic web applications * Almost all processing is done on server * High latency * Low interactivity
  • 6. Benefits of Using AJAX Enhance your sites by allowing quicker access to data. Reduce the amount of bandwidth used in data presentation. Make a web application that feels more like a native application.
  • 7. AJAX Workarounds Hidden IFRAME <SCRIPT> src hack Cookies
  • 8. Where to use AJAX Anywhere you have a search box, adding Google suggest functionality. Pages where you have a multi-step process. When working with large or highly interdependent datasets.
  • 9. Simple Ajax Application : How To Create a request object Make the request Handle the response
  • 10. Create a request object if browser is mozilla or safari or opera then create a new XMLHttpRequest otherwise if browser is IE create a new ActiveXObject otherwise error - browser does not support XMLHttpRequest IE 5,5.5,6 implement XHR as an ActiveX object (Msxml2.XMLHTTP/Microsoft.XMLHTTP) Mozilla 1.0+, Safari 1.2+, Opera 8+, IE7 provide XMLHttpRequest natively. All XHR objects have the same methods and properties.
  • 11. Code var xhr = null; if(window.XMLHttpRequest) // Mozilla,Safari, etc. { xhr = new XMLHttpRequest(); } else if(window.ActiveXObject) // < IE 7 { xhr = new ActiveXObject('Microsoft.XMLHTTP'); } Else { alert('Oops! Your browser does not support XMLHttpRequest'); }
  • 12. XHR Methods open(‘method’,’url’,asyncFlag) send(content) abort() getResponseHeader(“header”) setRequestHeader(“header”,”value”)
  • 13. XHR properties onreadystatechange readystate responseText responseXML status statusText
  • 14. Make the request set onreadystatechange to callback function cbProcessResponse open a request on the XHR object send the request through the XHR object “Same Site” rule “GET” or “POST” Asynchronous flag
  • 15. Code xhr.onreadystatechange=cbProcessResponse; xhr.open(’GET’,‘ajax.php’,true); function cbProcessResponse() { if(xhr.readystate==4 && xhr.status==200) { alert(xhr.responseText); } } /* readystate values 0 -> uninitialized 1 -> loading 2 -> loaded 3 -> interactive 4 -> completed */
  • 16. Handle Response: Parsing the XML // Our sample XML <?xml version=quot;1.0quot; encoding=quot;ISO-8859-1quot;?> <root> <response>OK</response> <msg>Hello World!</msg> </root> // Revised callback function function cbProcessResponse() { if(xhr.readystate==4 && xhr.status==200) { var xmlDoc = xhr.responseXML.documentElement; var s = x.getElementsByTagName('response')[0].firstChild.data; var m = x.getElementsByTagName('msg')[0].firstChild.data; alert(‘Response Code:’+s+’nMessage: ‘+m) } }
  • 17. Enter JSON JavaScript Object Notation JSON is a lightweight data-interchange format. JSON data are slightly simpler and slightly more in line with the rest of the JavaScript language than scripts for XML data. Find more about JSON at http://json.org //sample JSON { response: ‘OK’, msg: ‘Hello World’ }
  • 18. JSON How? JSON can be generated by all the popular server-side languages. Native/Library Support // Revised callback function to use JSON function cbProcessResponse() { if(xhr.readystate==4 && xhr.status==200) { var jsonData = eval(‘(‘+xhr.responseText+’)’); var s = jsonData.response; // easy ;-) var m = jsonData.msg; alert(‘Response Code:’+s+’nMessage: ‘+m) } } Doesn’t that look simpler?
  • 19. Frameworks A framework is a re-usable design for a software system with built-in generic functions for performing repetitive, natively unsupported operations. The Prototype JavaScript Framework is a JavaScript framework that provides an Ajax framework and other utilities. Download from http://prototypejs.org Others: YUI, Dojo, jQuery, mooTools
  • 20. Using Prototype.js Prototype provides the Ajax object to abstract the different browsers. Ajax.Request() Ajax.Updater(container, url[, options]) var pars = 'topic=ajax&framework=pjs'; Var url = '/cgi-bin/myAjaxHandler.cgi'; var myAjax = new Ajax.Request(url,{ method: quot;postquot;, // get/post parameters: pars, onComplete: cbProcessResponse // Our old callback function }); Ajax.PeriodicalUpdater(container, url[, options])
  • 21. Tips Don't overuse AJAX, the usability requirements for JavaScript applications are quite different than the requirements for regular web pages. Escape content sent to the server. Use AJAX activity indicators. http://www.napyfab.com/ajax-indicators/
  • 22. Debugging AJAX Always test your PHP/Server-side code before integrating it with the JavaScript side. Always check xhr.status Use FireBug to pin-point errors, and trace performance bottle-necks. Download from http://www.getfirebug.com/
  • 23. Resources AJAXIAN - http://ajaxian.com AJAX info - http://ajaxinfo.com AJAX Lesson - http://ajaxlessons.com Go4Expert - http://go4expert.com
  • 24. Thanks! Hussain Fakhruddin Teknowledge Software The wonderful audience.