Chapter 3: Interactive Web Applications

Similar documents
Chapter 3: Web Paradigms and Interactivity

Chapter 2: Interactive Web Applications

Chapter 2: Interactive Web Applications

Chapter 3: Web Paradigms and Interactivity

Credits: Some of the slides are based on material adapted from

AJAX. Gregorio López López Juan Francisco López Panea

What is AJAX? Ajax. Traditional Client-Server Interaction. What is Ajax? (cont.) Ajax Client-Server Interaction. What is Ajax? (cont.

Chapter 12: Advanced topic Web 2.0

Term Paper. P r o f. D r. E d u a r d H e i n d l. H o c h s c h u l e F u r t w a n g e n U n i v e r s i t y. P r e s e n t e d T o :

Client-side Web Engineering From HTML to AJAX

Web Programming Step by Step

JavaScript: Client-Side Scripting. Chapter 6

An introduction to creating Web 2.0 applications in Rational Application Developer Version 8.0

XML Processing and Web Services. Chapter 17

Core Ideas CHAPTER 1 PART. CHAPTER 2 Pre-Ajax JavaScript Communications Techniques CHAPTER 3 XMLHttpRequest Object CHAPTER 4 Data Formats

It is highly recommended that you are familiar with HTML and JavaScript before attempting this tutorial.

Connecting to a Database Using PHP. Prof. Jim Whitehead CMPS 183, Spring 2006 May 15, 2006

Rich-Internet Anwendungen auf Basis von ColdFusion und Ajax

Web application Architecture

Accessing External Databases from Mobile Applications

WWW. World Wide Web Aka The Internet. dr. C. P. J. Koymans. Informatics Institute Universiteit van Amsterdam. November 30, 2007

Performance Testing for Ajax Applications

Tutorial básico del método AJAX con PHP y MySQL

Software Requirements Specification For Real Estate Web Site

How To Embed A Youtube Video On A Computer Or Ipad Or Ipa Computer Or Tvplayer On A Pc Or Mac Or Ipro Or Ipo Or Ipode Or Iporode On A Mac Or Tvode On Your Computer Or Mac (

SUBJECT CODE : 4074 PERIODS/WEEK : 4 PERIODS/ SEMESTER : 72 CREDIT : 4 TIME SCHEDULE UNIT TOPIC PERIODS 1. INTERNET FUNDAMENTALS & HTML Test 1

DIPLOMA IN WEBDEVELOPMENT

Web Design Technology

AJAX and jmaki for Web 2.0 Development using Java. Inyoung Cho Java Technology Evangelist Sun Microsystems, Inc.

Web Development using PHP (WD_PHP) Duration 1.5 months

Overview. In the beginning. Issues with Client Side Scripting What is JavaScript? Syntax and the Document Object Model Moving forward with JavaScript

Developing a Web Server Platform with SAPI Support for AJAX RPC using JSON

Course Number: IAC-SOFT-WDAD Web Design and Application Development

Rich User Interfaces for Web-Based Corporate Applications

1. Introduction. 2. Web Application. 3. Components. 4. Common Vulnerabilities. 5. Improving security in Web applications

DOM, Jav Ja a v Script a and AJA AJ X A Madalina Croitoru IUT Mont Mon pellier

Other Language Types CMSC 330: Organization of Programming Languages

AJAX: Highly Interactive Web Applications. Jason Giglio.

ICE Trade Vault. Public User & Technology Guide June 6, 2014

Programming in HTML5 with JavaScript and CSS3

Adding Panoramas to Google Maps Using Ajax

Web application development landscape: technologies and models

USING MYWEBSQL FIGURE 1: FIRST AUTHENTICATION LAYER (ENTER YOUR REGULAR SIMMONS USERNAME AND PASSWORD)

Multimedia im Netz Online Multimedia Winter semester 2015/16

CMSC434 TUTORIAL #3 HTML CSS JavaScript Jquery Ajax + Google AppEngine Mobile WebApp HTML5

Application layer Web 2.0

World Wide Web Aka The Internet. Karst Koymans. Friday, October 2, 2015

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

DESIGNING HTML HELPERS TO OPTIMIZE WEB APPLICATION DEVELOPMENT

INTERNET PROGRAMMING AND DEVELOPMENT AEC LEA.BN Course Descriptions & Outcome Competency

How To Write A Web Server In Javascript

WIRIS quizzes web services Getting started with PHP and Java

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

CSCI110 Exercise 4: Database - MySQL

Ajax: A New Approach to Web Applications

Lepide Active Directory Self Service. Configuration Guide. Follow the simple steps given in this document to start working with

Computer Networks. Lecture 7: Application layer: FTP and HTTP. Marcin Bieńkowski. Institute of Computer Science University of Wrocław

Revisiting SQL Injection Will we ever get it right? Michael Sutton, Security Evangelist

J j enterpririse. Oracle Application Express 3. Develop Native Oracle database-centric web applications quickly and easily with Oracle APEX

Creating Web-Based EDI Applications with AJAX Joseph R. McVerry American Coders, Ltd & Ralph Naylor June 28, 2006

Introduction to BlackBerry Smartphone Web Development Widgets

A Brief Introduction to MySQL

jfingerprint Datasheet

Distance Examination using Ajax to Reduce Web Server Load and Student s Data Transfer

ISI ACADEMY Web applications Programming Diploma using PHP& MySQL

Preface. Motivation for this Book

From Desktop to Browser Platform: Office Application Suite with Ajax

Designing and Implementing an Online Bookstore Website

Deepak Patil (Technical Director) iasys Technologies Pvt. Ltd.

Implementing a Web-based Transportation Data Management System

General principles and architecture of Adlib and Adlib API. Petra Otten Manager Customer Support

THE CHALLENGE OF ADMINISTERING WEBSITES OR APPLICATIONS THAT REQUIRE 24/7 ACCESSIBILITY

LabVIEW Internet Toolkit User Guide

WEB DEVELOPMENT COURSE (PHP/ MYSQL)

Smartphone Application Development using HTML5-based Cross- Platform Framework

10CS73:Web Programming

DNS REBINDING DENIS BARANOV, POSITIVE TECHNOLOGIES


An introduction to creating JSF applications in Rational Application Developer Version 8.0

FileMaker Server 9. Custom Web Publishing with PHP

Client for a Browser-based Application Platform

A Tool for Evaluation and Optimization of Web Application Performance

Web Pages. Static Web Pages SHTML

HP Business Process Monitor

LICENSE4J LICENSE MANAGER USER GUIDE

Introduction to web development and JavaScript

AJAX Integration Approach for Collaborative Calendar-Server Web Services

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

Java Application Developer Certificate Program Competencies

OIT 307/ OIT 218: Web Programming

Application note: Connecting the to a Database

Server side scripting and databases

Advanced Web Development SCOPE OF WEB DEVELOPMENT INDUSTRY

Ajax Design and Usability

Abstract. Description

Time Tracking System with GWT

Part I. Web Technologies for Interactive Multimedia

Example. Represent this as XML

Google Web Toolkit. Progetto di Applicazioni Software a.a. 2011/12. Massimo Mecella

Precondition for a good understanding: knowledge of a higher programming language (e.g. C, Java, Perl, Pascal, Basic,... ) basic knowledge of html

Transcription:

Chapter 3: Interactive Web Applications 3.1 Web Server Interfaces 3.2 Server-Side Scripting (PHP) 3.3 Database Integration 3.4 Integration of Client-Side and Server-Side Scripts (AJAX) 3.5 Server-Side Programming with Java (Servlets, JSP) Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-48

Database Management Systems: A Quick Reminder Database: Structured collection of data items Stored persistently Provides acess to a common data pool for multiple users Database Management System (DBMS): Collection of programs for administration and usage of a database Various base models for DBMS:» Old: network model, hierarchical model» Dominant: relational model» Alternative: object-oriented model Relational databases: Good methodological support for design of data schema Standardized language interface SQL (Structured Query Language) Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-49

Prerequisites and Basic Architecture Database server Database 1 Database 2 Table 1.1 Table 1.2 Table 2.1 Table 2.2 Administration software User programs Other Servers (e.g. Web Server) Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-50

MySQL Open source software system Frequently used also in commercial context www.mysql.com Software package providing: Database server (mysqld) Administration program (mysqladmin) Command line interface (mysql) Various utility programs Communication between programs on local host: socket interface Bidirectional data stream exchange between programs Similar to files Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-51

Before Creating Anything in the Database... Using a database requires careful information design. Which are the data to be stored? Are there existing data to connect to? What is the schema of the data to be stored? Eg. Entity-Relationship diagrams as a tool Transformation into relational database schema (table design) Once a database if filled with data and in use, it is rather difficult to modify! Database schema design has to be carried out with great care! Most important rule: Avoid redundant storage of information Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-52

Creating Database Tables (1) Prerequisites: Database server running Socket connection between programs intact User accounts with adequate privileges known First step: Create database Container for many tables Requires special privileges Example SQL: create database music; Second step: Select database Sets the context for further interactions Example SQL: use music Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-53

Creating Database Tables (2) Third step: Create tables According to earlier design Each table should provide a unique identifier (primary key) SQL Example: create table song (code VARCHAR(5), title VARCHAR(20), artist VARCHAR(20), composer VARCHAR(20), runtime INT); Further steps: Defining keys, indices etc. Fourth step: Fill tables with data Simplest case: Individual SQL commands Better: Import from structured data file Frequent: Special programs for importing and creating data SQL Example: insert into song values ('1','One','U2','Adam Clayton, Bono, Larry Mullen & The Edge',272); Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-54

SQL Monitor Output Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-55

Queries with SQL Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-56

Databases, PHP and MySQL Special libraries for database access: "Database extensions" Generic for all database systems For specific database systems: "Vendor specific database extensions" For MySQL: MySQL-specific database extensions to PHP Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-57

Connecting to a Database from PHP First step: Connect to server Establish a connection for data exchange between Web Server/PHP plugin and database server Often local (sockets), if both programs on same machine Requires hostname, (database) username, password PHP function: mysql_connect()» Returns a link (resource) which can be used for mysql_close() Second step: Select a database Corresponds to the SQL command use Requires database name (and possibly link to server) PHP function: mysql_select_db()» Returns Boolean result (success) Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-58

Example: Connecting to Database <?php $link = mysql_connect('localhost','root','demopw') or die ('Could not connect: '.mysql_error()); echo 'Connected.<br/>'; mysql_select_db('music') or die ('Could not select db.'); echo 'DB selected.<br/>';...?> Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-59

Sending Database Queries from PHP Basic idea (as in all programming language/database integrations): SQL queries are given as strings to library functions Most important function in MySQL extensions to PHP: mysql_query() Requires SQL query as parameter (optionally link to server as 2nd param.) "Query" includes also INSERT, UPDATE, DELETE, DROP (SQL)! Return value in case of SELECT, SHOW, DESCRIBE and similar: Result set represented by resource value Special functions to retrieve result data as PHP data structures mysql_num_rows()» Number of rows returned mysql_fetch_array()» Reads one row of data and transforms it into an array» Makes the next row available Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-60

Example: Reading Data From a Query in PHP <?php... $query = 'SELECT * FROM song'; $result = mysql_query($query); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { foreach ($row as $element) { echo $element; echo ', '; } echo("<br/>");...?> dbaccess.php Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-61

Creating HTML Output From SQL Query (1) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <title>database table in HTML</title> </head> <?php $link = mysql_connect('localhost','root','demopw') or die ('Could not connect: '.mysql_error()); mysql_select_db('music') or die ('Could not select db.');?> dbaccess_html.php Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-62

Creating HTML Output From SQL Query (2)... <body> <h1>the following table is retrieved from MySQL:</h1> <table> <?php $query = 'SELECT * FROM song'; $result = mysql_query($query) or die ('Query failed'.mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t<tr>\n"; foreach ($row as $element) { echo "\t\t<td>"; echo $element; echo "</td>\n"; } echo "\t</tr>\n"; }?> </table> Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-63

Creating HTML Output From SQL Query (3)... <?php mysql_free_result($result); mysql_close($link);?> </body> </html> Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-64

Chapter 3: Interactive Web Applications 3.1 Web Server Interfaces 3.2 Server-Side Scripting (PHP) 3.3 Database Integration 3.4 Integration of Client-Side and Server-Side Scripts (AJAX) 3.5 Server-Side Programming with Java (Servlets, JSP) Christian Wenz: Ajax - schnell und kompakt. entwickler.press 2007 Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-65

Asynchronous JavaScript + HTML (AJAX) James Garrett 2005: http://www.adaptivepath.com/ideas/essays/archives/000385.php Catchy name for an idea which was in use already at the time: Google Suggest Google Maps Basic idea: Loading data from server is decoupled from changes in the presentation Advantages: User can interact fluidly with the application Information from server is fetched at regular intervals - display can always stay up-to-date AJAX is not a technology, it is a combination of known technologies XHTML, CSS, DOM, XML, XSLT, JavaScript, XMLHttpRequest There are AJAX-like applications which use neither JavaScript nor HTML E.g. using Flash and querying servers in the background Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-66

Asynchronicity Examples: Web mail access Autocompletion of forms (e.g. City based on Zip code) Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-67

AJAX and Client-Side Scripting AJAX applications are programs executed in the Web browser Require a runtime environment Usually programmed in JavaScript AJAX applications need to modify or construct HTML to be displayed in the browser Requires acess to loaded/displayed HTML Domain Object Model (DOM) is used for accessing and manipulating page content Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-68

JavaScript Object Tree Elements of the displayed document and other information can be accessed and manipulated Navigation: Mostly selection by "id" Starting point is often "document" object window, self, parent, top forms elements current frame document navigator images embeds (button, checkbox, radio, text,...) frames anchors location... history Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-69

DOM Reminder DOM is a collection of functions which make it possible to access and manipulate HTML and XML documents in the browser DOM ist a standardised API (Application Programming Interface) Usable with several programming languages Examples of DOM object properties and methods: nodename, nodevalue, nodetype, attributes getelementbyid() parentnode, haschildnodes(); childnodes, firstchild, lastchild, previoussibling, nextsibling; createelement(); createtextnode(); insertbefore(), replacechild(), removechild(), appendchild(); Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-70

AJAX and Server-Side Scripting AJAX applications make particular sense when the data loaded from the server changes dynamically PHP scripts or other server-side dynamics Database connectivity For ease of understanding (only!): Most examples in the following deal with static Web pages only Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-71

Request Construction and Handling Main functionalities required: Construction of a request to be sent to the server Sending a request to the server Waiting (asynchronously) until server responds Calling functions to analyze server response All these functionalities are realized in one single object (in the sense of object-orientation): XMLHttpRequest Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-72

Basic Control Flow http://www.ibm.com/developerworks, Dojo framework Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-73

XMLHttpRequest Outlook Web Access for Internet Explorer 5 (end 90s): XMLHttpRequest object invented at Microsoft Realized as ActiveX object Mozilla 1.4 (Netscape 7.1) and derivates (including Firefox): Native XMLHttpRequest object for JavaScript Independent of Active X Other manufacturers: Followed step by step: Konqueror, Apple Safari, Opera, icab Since Internet Explorer 7 ActiveX no longer required Just JavaScript Under W3C standardization (Working draft August 2009) Long term situation for creating XMLHttpRequest object will be: var XMLHTTP = new XMLHttpRequest(); Currently we have to fight with browser incompatibilities! Frameworks like Prototype can help Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-74

Platform Independent Creation of XMLHttpRequest var XMLHTTP = null; if (window.xmlhttprequest) { XMLHTTP = new XMLHttpRequest(); } else if (window.activexobject) { } try { XMLHTTP = new ActiveXObject("Msxml2.XMLHTTP"); } catch (ex) { } try { XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP"); } catch (ex) {} IE < 7.0 or Standard For older IE versions than 6.0 Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-75

Construction of a HTTP Request open() method of XMLHTTPRequest object Note: There is no interaction with the server involved, despite the name Required parameters: HTTP method: GET, POST or HEAD URL to send the request to Optional parameters: Asynchronous or synchronous treatment (default asynchronous = true) Username and password for authentication Examples: XMLHTTP.open("GET", "fibonacci.php?fib=12") XMLHTTP.open("POST", "/start.html", false, un, pwd); Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-76

Sending a Request Before sending: XMLHTTP.setRequestHeader() Setting headers for the request Recommended: Content-Type (MIME type) XMLHTTP.send() Sends request to server Parameter: In the simplest case (in particular GET method): null For more complex cases: "Request entity body" is given as parameter» Mainly for POST method Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-77

States of an XMLHttpRequest Object 0 UNSENT Just created 1 OPENED Request constructed, sending Header part of response arrived 2 HEADERS_ RECEIVED Body is being received 3 LOADING Response has been received completely 4 DONE Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-78

Asynchronous Reaction by Event Handler In order to react to the received response: Function has to be called when state 4 is reached Registering an event handler: Callback function, called when event takes place Similar to event handling for user interfaces (Java Swing, Flash) For Ajax: Callback method registered with XMLHTTPRequest object Event = State 4 is reached More general: Called at any state change XMLHTTP.onreadystatechange = function; XMLHTTP.readystate gives current state (as number) Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-79

Example: Very Simple Request...<body> <script type = "text/javascript"> var XMLHTTP = new XMLHttpRequest(); function dataoutput() { if (XMLHTTP.readyState == 4) { var d = document.getelementbyid("data"); d.innerhtml += XMLHTTP.responseText; } } window.onload = function() { XMLHTTP.open("GET", "data.txt", true); XMLHTTP.onreadystatechange = dataoutput; XMLHTTP.send(null); } </script> </body> <p id="data">data from server: </p> </html> Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-80

AJAX and XML The server response (essentially text) needs to be analysed XML Supports arbitrarily structured information Is fully supported by JavaScript and DOM Servers should return data as XML Problem (currently): Browser incompatibilities Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-81

Example XML Data <?xml version="1.0" encoding="utf-8"?> <ResultSet totalresultsavailable="24900000" totalresultsreturned="10"> <Result> <Title>AJAX - Wikipedia</Title> <Summary>Background about the web development technique for creating interactive web applications.</summary> <Url>http://en.wikipedia.org/wiki/AJAX</Url> </Result> <Result> <Title>Ajax: A New Approach to Web Applications</Title> <Summary>Essay by Jesse James Garrett from Adaptive Path.</Summary> <Url>http://www.adaptivepath.com/p...s/000385.php</Url> </Result> <Result> <Title>AFC Ajax</Title> <Summary>Official site. Club information, match reports, news, and much more.</summary> <Url>http://www.ajax.nl/</Url> </Result> </ResultSet> From C.Wenz Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-82

AJAX Program Creating a HTML Table from XML Fixed HTML text : <body> <p> <span id="anzahl">0</span> von <span id="gesamt">0</span> Treffern: </p> <table id="treffer"> <thead> <tr><th>titel</th><th>beschreibung</th><th>url</th></tr> </thead> </table> </body> Script has to fill the missing data from XML response. Basic structure of script as above. From C.Wenz Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-83

Transformer Callback Function (1) function DatenAusgeben() { if (XMLHTTP.readyState == 4) { var xml = XMLHTTP.responseXML; var anzahl = document.getelementbyid("anzahl"); var gesamt = document.getelementbyid("gesamt"); anzahl.innerhtml = xml.documentelement.getattribute("totalresultsreturned"); gesamt.innerhtml = xml.documentelement.getattribute("totalresultsavailable"); var treffer = document.getelementbyid("treffer"); var tbody = document.createelement("tbody"); var ergebnisse = xml.getelementsbytagname("result");... Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-84

Transformer Callback Function (2)... for (var i=0; i<ergebnisse.length; i++) { var zeile = document.createelement("tr"); var titel = document.createelement("td"); var beschreibung = document.createelement("td"); var url = document.createelement("td"); var titeltext, beschreibungtext, urltext; for (var j=0; j<ergebnisse[i].childnodes.length; j++) { var knoten = ergebnisse[i].childnodes[j]; switch (knoten.nodename) { case "Title": titeltext = document.createtextnode( knoten.firstchild.nodevalue); break; case "Summary": beschreibungtext = document.createtextnode( knoten.firstchild.nodevalue); break; case "Url": urltext = document.createtextnode( knoten.firstchild.nodevalue); break; } } Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-85

Transformer Callback Function (2)... for (var i=0; i<ergebnisse.length; i++) {... for (var j=0; j<ergebnisse[i].childnodes.length; j++) {... titel.appendchild(titeltext); beschreibung.appendchild(beschreibungtext); url.appendchild(urltext); } } zeile.appendchild(titel); zeile.appendchild(beschreibung); zeile.appendchild(url); tbody.appendchild(zeile); } treffer.appendchild(tbody); Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-86

AJAJ? Simple Serialization with JSON XML Serialization of data Tends to be long Many redundant elements Occupies a lot of bandwidth Alternative Serialization: JSON (JavaScript Object Notation) { "ResultSet": { "totalresultsavailable": "24900000", "totalresultsreturned": 10, "Result": [ { "Title": "AJAX - Wikipedia", "Url":"http:\/\/en.wikipedia.org\/wiki\/AJAX" }, { "Title":"Ajax: A New Approach to Web Applications", "Url":"http:\/\/www.adaptivepath.com\/p.../000385.php" } ] } } Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-87

Problems with AJAX Back button Browsers do not store dynamically modified pages in history Polling Browser send more requests at a more regular pace; i.e the base assumptions for traffic engineering change Bookmarks It is difficult to set a bookmark at a specifc state of a dynamically created flow of pages Solution attempts use the document-internal anchors (#) Indexing by search engines Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-88

Example: Bookmarking Support When processing response: location.hash = "#" + escape(url); window.onload = function() { if (location.hash.length > 1) { url = unescape(location.hash.substring(1)); ladeurl(); } } Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-89

Sajax: Framework for AJAX (in PHP) Example for a framework supporting Ajax Sajax (Simple Ajax) http://www.modernmethod.com/sajax Open Source Framework (library) for several scripting languages, including PHP Abstracts from technical details of AJAX Write AJAX applications without knowing about XMLHttpRequest Basic idea: Create a server-side dynamic function (in PHP) "Export" this function with Sajax (sajax_export('functionname')) In the JavaScript section of the page, call sajax_show_javascript() (a PHP function generating JavaScript) Corresponding to the server-side function, now a JavaScript function exists (x_functionname) which calls the server-side function asynchrounously (i.e. a callback function is given as parameter) Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-90

Examples of AJAX Applications Maps: Google Maps, OpenStreetMap Office: AjaxWrite, neximage Social software: Flickr, Del.icio.us, Last.fm, *VZ Netzwerke Mail: Google Mail Web search: Google Suggest CRM: 24SevenOffice Ludwig-Maximilians-Universität München Prof. Hußmann Multimedia im Netz 3-91