Introduction to AJAX Sue Brandreth. What is Ajax?

Slides:



Advertisements
Similar presentations
Ajax. Overview of Ajax History In the 1990s, most web sites were based on complete HTML pages; each user action required that the page be re-loaded from.
Advertisements

Dodick Zulaimi Sudirman Lecture 12 Introduction to AJAX Pengantar Teknologi Internet Introduction to Internet Technology.
9. AJAX & RIA. 2 Motto: O! call back yesterday, bid time return. — William Shakespeare.
6/3/2015eBiquity1 Tutorial on AJAX Anubhav Kale (akale1 AT cs DOT umbc DOT edu)
Server-Side vs. Client-Side Scripting Languages
AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 2006.
Cloud Computing Lecture #7 Introduction to Ajax Jimmy Lin The iSchool University of Maryland Wednesday, October 15, 2008 This work is licensed under a.
Dynamic Web Pages Bert Wachsmuth. Review  Internet, IP addresses, ports, client-server, http, smtp  HTML, XHTML, XML  Style Sheets, external, internal,
Does Ajax suck? CS575 Spring 2007 Chanwit Suebsureekul.
A closer look Dynamic Webpages Jessica Meyerson March 1, 2011.
The World Wide Web By: Brittney Hardin, Carlos Smith, and David Wilkins.
Web Design Basic Concepts.
Ryan Putz. Outline  What is Ajax?  Member Technologies  Methodology  When and When Not To Use  Who’s Using Ajax?  Code Examples.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Introduction to AJAX AJAX Keywords: JavaScript and XML
JavaScript & jQuery the missing manual Chapter 11
May 16 – 18, 2007 Copyright 2007, Data Access Worldwide May 16 – 18, 2007 Copyright 2007, Data Access Worldwide Build Great Web Application 'Fast and Easy'
Ruth Betcher Ruth Christie
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Lecture 12 – AJAX SFDV3011 – Advanced Web Development Reference: 1.
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
 2008 Pearson Education, Inc. All rights reserved Ajax-Enabled Rich Internet Applications.
AJAX Without the “J” George Lawniczak. What is Ajax?
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
Instructor, Dr. Khalili Bahram Jeevan Kumar Gogineni.
The Document Object Model. The Web B.D, A.D. They aren’t web pages, they’re document objects A web browser interprets structured information. A server.
Ajax. –Asynchronous JavaScript and XML –Umbrella term for technologies that often: Use client-side scripting for layout and formatting Use less than full.
Weekend MS CS Program Internet and Web Technologies COT 5930 Web Project Development - Ajax Dr. Roy Levow, Associate Chair & Professor
Web Applications BIS4430 – unit 8. Learning Objectives Explain the uses of web application frameworks Relate the client-side, server-side architecture.
Random Logic l Forum.NET l AJAX Behind the buzz word Forum.NET ● January 23, 2006.
Ventsislav Popov Crossroad Ltd.. 1. What is AJAX?  AJAX Concept  ASP.NET AJAX Framework 2. ASP.NET AJAX Server Controls  ScriptManager, UpdatePanel.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Telerik Software Academy ASP.NET Web Forms Telerik Software Academy ASP.NET Web Forms.
Lecture 9: AJAX, Javascript review..  AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype,
Ajax. –Asynchronous JavaScript and XML –Umbrella term for technologies that often: Use client-side scripting for layout and formatting Use less than full.
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
Chapter 16: Ajax-Enabled Rich Internet Applications with XML and JSON TP2543 Web Programming Mohammad Faidzul Nasrudin.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Event Handling & AJAX IT210 Web Systems. Question How do we enable users to dynamically interact with a website? Answer: Use mouse and keyboard to trigger.
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
AJAX AJAX Asynchronous JavaScript and XML --- MADHAVI
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.
AJAX – Asynchronous JavaScript And XML By Kranthi Kiran Nuthi CIS 764 Kansas State University.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
 AJAX technology  Rich User Experience  Characteristics  Real live examples  JavaScript and AJAX  Web application workflow model – synchronous vs.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
Ajax! Ajax Programming Ajax! Ajax Programming. Ajax! Ajax Programming Take a look at a typical desktop application (Spreadsheet app, etc.) The program.
Ajax 101 for CF Programmers Randy Brown – Michigan State University
Ajax SUBMITTED BY NITIN RAMANI C.S.E 3 rd Y 5 th S R.N CS SUBMITTED TO PRO. PUSHPARAJ PATEL SIR.
Ajax & Client-side Dynamic Web Gunwoo Park (Undergraduate)
What is AJAX ? Asynchronous Javascript and XML.
JavaScript and Ajax (Ajax Tutorial)
Working with Client-Side Scripting
AJAX and REST.
AJAX.
Asynchronous Java script And XML Technology
AJAX.
Giuseppe Attardi Università di Pisa
AJAX Robin Burke ECT 360.
Giuseppe Attardi Università di Pisa
Introduction to AJAX Sue Brandreth.
JavaScript & jQuery AJAX.
MIS JavaScript and API Workshop (Part 3)
Introduction to AJAX and JSON
Introduction to AJAX and JSON
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Presentation transcript:

Introduction to AJAX Sue Brandreth

What is Ajax?

A synchronous J avaScript A nd X mlHttpRequest (XHR) –Some use XML, but that is misleading

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) –Server-side technology

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. e.asphttp:// e.asp Only the ‘span’ part of the html code is changed.

Data Exchange in AJAX In AJAX:

What is AJAX? Asynchronous Javascript and XML –Not all AJAX apps involve XML Combination of technologies –XHTML, CSS, DOM –XML, XSLT, XMLHttp, JavaScript –Some server scripting language A method for building more responsive and interactive applications

AJAX Components XHTML and CSS Ajax applies these familiar Web standards for styling the look and feel of a page and to markup those areas on a page that will be targeted for data updates. DOM (document object model) Ajax uses the DOM to manipulate dynamic page views for data and to walkthrough documents to “cherrypick” data. The DOM enables certain pieces of an Ajax page to be transformed and updated with data. XML, JSON (Javascript Object Notation), HTML, or plain text Ajax can use any of these standards to provide structure to the data it passes to and from a page. XMLHttpRequest object The heavy lifter for Ajax: It’s a javascript object embedded in most modern browsers that sets up data request/response pipelines between client and server. Javascript Lightweight programming language that Ajax uses for instructions to bind all of the components together.

Why AJAX? Want to make your applications more interactive Want to incorporate data from external Web Services Don’t want your users to have to download a plugin

Client vs. Server Scripting Client scripting –Web browser does all the work Server Scripting –Web server does all the work AJAX leverages both client and server side scripting

How AJAX Works

AJAX Web Interaction What you don’t see Data reload happens in the background JavaScript queries the server to get the proper data without you knowing it Page updates without a screen “reload”

Potential Problems Javascript MUST be enabled Back button doesn’t always work Pages can be difficult to bookmark Search engines may not be able to index all portions of an AJAX site Cross browser differences in how XML is dealt with

Some AJAX examples Google Calendar Flickr Rojo Meebo Backpack

Basic AJAX Components Server-side Component –Communicates with the database, or web service –Can be written in any server-side language (PHP, ASP, Coldfusion, etc) Client-side Component –Written in Javascript, often uses XMLHttp –Accesses the server side page in the background

Hidden Frame Method Communication with server takes place in a frame that user can’t see Back and Forward buttons still work If something goes wrong user receives no notification

XMLHttp Method Code is cleaner and easier to read Able to determine if there is a failure No browser history, Back and Forward buttons break

Potential Uses for AJAX Error checking in Forms AutoSuggest Drag and Drop objects functionality Dynamically move view around on image or map Preload content you want to show later Apply limits to search results and get new results quickly

Why Ajax? XHR Support across all browsers –Based on DOM, CSS, XHTML Emergence of broadband –AJAX-based JavaScript can take considerable bandwidth to download The “Killer App” - Google Maps A Catchy Acronym –Coined by Jesse James Garrett of Adaptive Path (February 2005)

Source: Garrett(2005)

Why Ajax? Source: Garrett(2005)

AJAX Alternatives Adobe Flash –Requires a plug-in So what? It comes already with almost every browser Java Web Start/Applets.NET – No Touch Deployment –Both need a runtime preinstalled Handheld device browsers generally do not support the full range of Ajax technologies.

Implementing AJAX To implement AJAX we need to answer three questions: –What triggers the AJAX request? Usually a JavaScript event (onblur, onclick, etc.) –What is the server process that handles the AJAX request and issues the response? Some kind of URL (use a Service Locator) –What processes the response from the server(what is the callback method)? A JavaScript function that gets the response and manipulates the DOM, based on the text returned.

XmlHttpRequest Object (XHR) The ‘heart’ of AJAX First implemented in IE in 1997 as part of the new DHTML standard Response comes in one of two properties: –responseXML – Returns a DOM document (can use functions such as, getElementById() ) –responseText – A text string (can be HTML, or even JavaScript code)

XHR : Creating

XHR : Sending the Request true = asynchronous

XHR : Using a callback handler

Handling the Response Response can be one of the following: –Formatted data (XML, other custom format) XMLHttpRequest.responseXML Decouples the server from presentation issues Could perform XSLT transformation on returned XML –HTML XMLHttpRequest.responseText Server generates HTML, script “injects” HTML via innerHTML Server is now concerned with presentation –JavaScript XMLHttpRequest.responseText Use the eval() JavaScript command Again, our server code is concerned with presentation

AJAX Concerns Security Browser Compatibility Accessibility The Back Button What if JavaScript is Turned Off?

AJAX and the Back Button Huge usability issue Returning to the previous state may not be possible when a page is updated dynamically Difficult to bookmark on a particular page state Really Simple History (RSH) framework addresses these issues –

AJAX Security – Server of Origin Policy

AJAX Security Browsers impose security restrictions –Cannot make requests via the XHR outside of the domain the web page came from Can set security on IE to get around this (but you really don’t want to) Mozilla-based browsers require digitally signing your script –User must approve going to site. Firefox requires additional code

AJAX Security Calling third-party web-services –Application Proxies – Call the web-service from a servlet –Apache Proxy – Configure Apache to invisibly reroute from the server to the target web service domain

Problems with JavaScript Most Java developers know enough JavaScript to be dangerous. –If you don’t know what you are doing, you could cause memory leaks on the client machine. Most JavaScript functionality can be factored out and encapsulated

Ajax Without the J It would be nice to encapsulate all of the JavaScript within our components, so we don’t have to write any JavaScript. JavaServer Faces (JSF) provides a way to accomplish this.