AJAX Compiled from “AJAX Programming” [Sang Shin]

Slides:



Advertisements
Similar presentations
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Advertisements

Introduction to Ajax Introduction to Ajax Sang Shin Java Technology Architect Sun Microsystems, Inc.
9. AJAX & RIA. 2 Motto: O! call back yesterday, bid time return. — William Shakespeare.
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.
Does Ajax suck? CS575 Spring 2007 Chanwit Suebsureekul.
1 JavaScript & AJAX CS , Spring JavaScript.
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
The Document Object Model (DOM) & Asynchronous Javascript And XML (AJAX) : an introduction UFCEKG-20-2 : Data, Schemas and Applications.
Interactive Web Application with AJAX
Ajax (Asynchronous JavaScript and XML). AJAX  Enable asynchronous communication between a web client and a server.  A client is not blocked when an.
JavaScript & jQuery the missing manual Chapter 11
1 Fall 2006 Florida Atlantic University Department of Computer Science & Engineering COT 6930 Advanced Internet Programming Dr. Roy Levow Day 1.
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.
AJAX Without the “J” George Lawniczak. What is Ajax?
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
AJAX and Java ISYS 350. AJAX Asynchronous JavaScript and XML: – Related technologies: JavaScript, Document Object Model, XML, server-side script such.
Intro to Ajax Fred Stluka Jan 25, /25/2006Intro to AjaxFred Stluka2 What is Ajax? "Asynchronous JavaScript and XML" New name for an old technique:
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.
J.Holvikivi 1 Ajax & scripts Jaana Holvikivi Metropolia.
Ajax. What is Ajax? Ajax = Asynchronous JavaScript and XML A group of interrelated Web development techniques used for creating interactive Web applications.
Network Computing Laboratory Ajax - Rich User Experience Initiative - Dec Inseok Hwang.
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.
AJAX (also known as: XMLHTTP, Remote Scripting, XMLHttpRequest, etc.) Matt Warden.
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 محمد احمدی نیا 2 Of 27 What is AJAX?  AJAX = Asynchronous JavaScript and XML.  AJAX is not a new programming language, but.
AJAX Compiled from “AJAX Programming” [Sang Shin] (Asynchronous JavaScript and XML)
-By V.Gouthaman. INTRODUCTION Ajax (shorthand for asynchronous JavaScript and XML) is a group of interrelated web development techniques used on the client-side.
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:
Ajax for Dynamic Web Development Gregory McChesney.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
AJAX Asynchronous JavaScript and XML 1. AJAX Outline What is AJAX? Benefits Real world examples How it works 2.
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
Introduction to AJAX Sue Brandreth. What is Ajax?
AJAX – Asynchronous JavaScript And XML By Kranthi Kiran Nuthi CIS 764 Kansas State University.
INNOV-2: Build a Better Web Interface Using AJAX Chris Morgan Pandora Software Systems
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! Ajax Programming Ajax! Ajax Programming. Ajax! Ajax Programming Take a look at a typical desktop application (Spreadsheet app, etc.) The program.
A New Way To Web Applications Development Tin Htut Htut Naing Oo Myanmar Information Technology.
CITA 330 Section 10 Web Remoting Techniques. Web Remoting Web Remoting is a term used to categorize the technique of using JavaScript to directly make.
AJAX. Objectives Understand and apply AJAX Using AJAX in DOJO library.
AJAX Rohan B Thimmappa. What Is AJAX? AJAX stands for Asynchronous JavaScript and XML. AJAX stands for Asynchronous JavaScript and XML. A remote scripting.
JavaScript and Ajax (Ajax Tutorial)
CSE 154 Lecture 11: AJAx.
Not a Language but a series of techniques
AJAX and REST.
XMLHttp Object.
AJAX – Asynchronous JavaScript and XML
AJAX.
AJAX.
CSE 154 Lecture 11: AJAx.
CSE 154 Lecture 22: AJAX.
AJAX Robin Burke ECT 360.
ISC440: Web Programming 2 AJAX
JavaScript & jQuery AJAX.
Chengyu Sun California State University, Los Angeles
AJAX CS-422 Dick Steflik.
Intro to Ajax Fred Stluka Jan 25, 2006.
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
AJAX By Prof. B.A.Khivsara
Software Engineering for Internet Applications
Presentation transcript:

AJAX Compiled from “AJAX Programming” [Sang Shin]

AJAX “JavaScript technology doesn’t suck, after all”

Rich User Experience   Take a look at a typical desktop application (Spreadsheet app, etc.)   The program responses intuitively and quickly   The program gives a user meaningful feedback's instantly A cell in a spreadsheet changes color when you hover your mouse over it Icons light up as mouse hovers them   Things happen naturally No need to click a button or a link to trigger an event

Characteristics of Conventional Web Applications   “Click, wait, and refresh” user interaction Page refreshes from the server needed for all events, data submissions, and navigation   Synchronous “request/response” communication model The user has to wait for the response   Page-driven: Workflow is based on pages Page-navigation logic is determined by the server

Issues of Conventional Web Application   Interruption of user operation Users cannot perform any operation while waiting for a response   Loss of operational context during refresh Loss of information on the screen Loss of scrolled position   No instant feedback's to user activities A user has to wait for the next page   Constrained by HTML Lack of useful widgets These are the reasons why Rich Internet Application (RIA) technologies were born.

UI Technology Richness Scale

Rich Internet Application (RIA) Technologies   Applet (Swing)   Macromedia Flash   Java WebStart   DHTML   DHTML with Hidden IFrame   AJAX

AJAX  Asynchronous JavaScript and XML  AJAX is using JavaScript, namely the XmlHttpRequest object, to communicate asynchronously with a server-side component and dynamically update the source of an HTML page based on the resulting XML/Text response.

AJAX

AJAX

AJAX   DHTML plus Asynchronous communication capability through XMLHttpRequest   Pros Most viable RIA technology so far Tremendous industry momentum Several toolkits and frameworks are emerging No need to download code & no plug-in required   Cons Still browser incompatibility JavaScript is hard to maintain and debug   AJAX-enabled JSF components will help

Why AJAX?   Intuitive and natural user interaction No clicking required Mouse movement is a sufficient event trigger   "Partial screen update" replaces the "click, wait, and refresh" user interaction model Only user interface elements that contain new information are updated (fast response) The rest of the user interface remains displayed without interruption (no loss of operational context)   Data-driven (as opposed to page-driven) UI is handled in the client while the server provides data   Asynchronous communication replaces "synchronous request/response model." A user can continue to use the application while the client program requests information from the server in the background Separation of displaying from data fetching

Real-Life Examples of AJAX Apps   Google maps   Goolgle Suggest   NetFlix   Gmail   Yahoo Maps (new) Many more are popping everywhere

Technologies Used In AJAX   JavaScript Loosely typed scripting language JavaScript function is called when an event in a page occurs Glue for the whole AJAX operation   DOM API for accessing and manipulating structured documents Represents the structure of XML and HTML documents   CSS Allows for a clear separation of the presentation style from the content and may be changed programmatically by JavaScript   XMLHttpRequest JavaScript object that performs asynchronous interaction with the server

XMLHttpRequest   JavaScript object   Adopted by modern browsers Mozilla™, Firefox, Safari, and Opera Communicates with a server via standard HTTP GET/POST   XMLHttpRequest object works in the background for performing asynchronous communication with the backend server Does not interrupt user operation

Server-Side AJAX Request Processing   Server programming model remains the same It receives standard HTTP GETs/POSTs Can use Servlet, JSP, JSF,...   With minor constraints More frequent and finer-grained requests from client Response content type can be   text/xml   text/plain   text/json   text/javascript

AJAX: Sample App

Steps of AJAX Operation   1.A client event occurs   2.An XMLHttpRequest object is created   3.The XMLHttpRequest object is configured   4.The XMLHttpRequest object makes an async. request   5.The ValidateServlet returns an XML document containing the result   6.The XMLHttpRequest object calls the callback() function and processes the result   7.The HTML DOM is updated

XMLHttpRequest Properties   onreadystatechange Set with an JavaScript event handler that fires at each state change   readyState – current status of request 0 = uninitialized 1 = loading 2 = loaded 3 = interactive (some data has been returned) 4 = complete   status HTTP Status returned from server: 200 = OK

XMLHttpRequest Properties   responseText String version of data returned from the server   responseXML XML document of data returned from the server   statusText Status text returned from server

AJAX: Another App

AJAX: Coding Involved  index.jsp Page Auto-Complete Form <input type="text" size="20" autocomplete="off" id="completeField" name="id" onkeyup="doCompletion();"> </form>

AJAX: Coding Involved (2)  AutoComplete Event Handler function doCompletion() { if (completeField.value == "") { clearTable(); } else { var url = "autocomplete?action=complete&id=" + escape(completeField.value); escape(completeField.value); var req = initRequest(url); req.onreadystatechange = function() { if (req.readyState == 4) { if (req.readyState == 4) { if (req.status == 200) { parseMessages(req.responseXML); } else if (req.status == 204){ clearTable(); }} }; }; req.open("GET", url, true); req.send(null);}}

AJAX: Coding Involved (3)  AutoComplete XMLHttpRequest function initRequest(url) { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if (window.ActiveXObject) { isIE = true; return new ActiveXObject("Microsoft.XMLHTTP"); }}

AJAX: Coding Involved (4)  AutoComplete Servlet doGet() public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {... String targetId = request.getParameter("id"); Iterator it = employees.keySet().iterator(); while (it.hasNext()) { EmployeeBean e = (EmployeeBean)employees.get((String)it.next()); if ((e.getFirstName().toLowerCase().startsWith(targetId) || e.getLastName().toLowerCase().startsWith(targetId)) && !targetId.equals("")) { sb.append("<employee>"); sb.append(" " + e.getId() + " "); sb.append(" " + e.getFirstName() + " "); sb.append(" " + e.getLastName() + " "); sb.append("</employee>"); namesAdded = true; } // if } // while if (namesAdded) { response.setContentType("text/xml"); response.setHeader("Cache-Control", "no-cache"); response.getWriter().write(" " + sb.toString() + " "); } else { response.setStatus(HttpServletResponse.SC_NO_CONTENT);} } // doGet

AJAX: Coding Involved (5)  Processing the response function parseMessages(responseXML) { clearTable(); var employees = responseXML.getElementsByTagName("employees")[0]; if (employees.childNodes.length > 0) { completeTable.setAttribute("bordercolor", "black"); completeTable.setAttribute("border", "1"); } else { clearTable();} for (loop = 0; loop < employees.childNodes.length; loop++) { var employee = employees.childNodes[loop]; var firstName = employee.getElementsByTagName("firstName")[0]; var lastName = employee.getElementsByTagName("lastName")[0]; var employeeId = employee.getElementsByTagName("id")[0]; appendEmployee(firstName.childNodes[0].nodeValue,lastName.child Nodes[0].nodeValue, employeeId.childNodes[0].nodeValue); }}