AJAX. Overview of Ajax Ajax is not an API or a programming language Ajax aims to provide more responsive web applications In normal request/response HTTP.

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Introduction to Ajax.
Advertisements

HTML Forms. collect information for passing to server- side processes built up from standard widgets –text-input, radio buttons, check boxes, option lists,
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.
The Web Warrior Guide to Web Design Technologies
9. AJAX & RIA. 2 Motto: O! call back yesterday, bid time return. — William Shakespeare.
1 Cleaning up the Internet Using AJAX, SOAP and Comet CS526 Mike Gerschefske Justin Gray James Yoo 02 May 2006.
19-Jun-15 Ajax. The hype Ajax (sometimes capitalized as AJAX) stands for Asynchronous JavaScript And XML Ajax is a technique for creating “better, faster,
5/3/2006 Mike/Justin/JYoo AJAX/SOAP/Comet 1 Cleaning up the Internet Using AJAX, SOAP and Comet CS526 Mike Gerschefske Justin Gray James Yoo 02 May 2006.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
JQuery CS 268. What is jQuery? From their web site:
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
The Document Object Model (DOM) & Asynchronous Javascript And XML (AJAX) : an introduction UFCEKG-20-2 : Data, Schemas and Applications.
Introduction to AJAX AJAX Keywords: JavaScript and XML
Ajax (Asynchronous JavaScript and XML). AJAX  Enable asynchronous communication between a web client and a server.  A client is not blocked when an.
PHP and AJAX ISYS 475. AJAX Asynchronous JavaScript and XML: – JavaScript, Document Object Model, Cascade Style Sheet, XML, server-side script such as.Net,
JavaScript & jQuery the missing manual Chapter 11
1 Forms A form is the usual way that information is gotten from a browser to a server –HTML has tags to create a collection of objects that implement this.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
AJAX and Java ISYS 350. AJAX Asynchronous JavaScript and XML: – Related technologies: JavaScript, Document Object Model, XML, server-side script such.
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
Chapter 8 Cookies And Security JavaScript, Third Edition.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Introduction to Ajax.
JavaScript - A Web Script Language Fred Durao
AJAX Compiled from “AJAX Programming” [Sang Shin] (Asynchronous JavaScript and XML)
Fall 2006 Florida Atlantic University Department of Computer Science & Engineering COP 4814 – Web Services Dr. Roy Levow Part 2 – Ajax Fundamentals.
Rails & Ajax Module 5. Introduction to Rails Overview of Rails Rails is Ruby based “A development framework for Web-based applications” Rails uses the.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
Web Technology Introduction AJAXAJAX. AJAX Outline  What is AJAX?  Benefits  Real world examples  How it works  Code review  Samples.
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
the acronym for Asynchronous JavaScript and XML.
SYST Web Technologies SYST Web Technologies AJAX.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Scripting Languages Client Side and Server Side. Examples of client side/server side Examples of client-side side include: JavaScript Jquery (uses a JavaScript.
AJAX Asynchronous JavaScript and XML 1. AJAX Outline What is AJAX? Benefits Real world examples How it works 2.
JQuery and AJAX WEB Technologies : PHP Programming Language.
SE-2840 Dr. Mark L. Hornick 1 Introduction to Ajax Asynchronous Javascript And XML.
HTML Forms.
John Maver (978)
CHAPTER 8 AJAX & JSON WHAT IS AJAX? Ajax lets you…
Dave Salinas. What is XML? XML stands for eXtensible Markup Language Markup language, like HTML HTML was designed to display data, whereas XML was designed.
AJAX Use Cases for WSRP Subbu Allamaraju BEA Systems Inc WSRP F2F Meeting, May 2006.
AJAX in Ruby-on-Rails. Ruby on Rails and AJAX AJAX can be done with just Javascript Easier if you use libraries –Prototype –SAJAX –jQuery Libraries only.
AJAX – Asynchronous JavaScript And XML By Kranthi Kiran Nuthi CIS 764 Kansas State University.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
JavaScript and Ajax Week 10 Web site:
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.
NCCUCS 軟體工程概論 Lecture 5: Ajax, Mashups April 29, 2014.
National College of Science & Information Technology.
JavaScript and Ajax (Ajax Tutorial)
Not a Language but a series of techniques
Play Framework: Introduction
Subbu Allamaraju BEA Systems Inc
AJAX.
AJAX Robin Burke ECT 360.
Forms, cont’d.
ISC440: Web Programming 2 AJAX
JavaScript & jQuery AJAX.
AJAX CS-422 Dick Steflik.
PHP and JSON Topics Review JSON.
Presentation transcript:

AJAX

Overview of Ajax Ajax is not an API or a programming language Ajax aims to provide more responsive web applications In normal request/response HTTP cycles, the browser locks waiting for the response and an entire page must be displayed With Ajax, asynchronous requests may be made and responses are used to update part of a page – User can continue to interact with a page while the request is in progress – Less data needs to be transmitted – Page update is quicker because only a part of a page is modified

Approaches to Ajax The iframe element can be hidden and it allows asynchronous requests to a server – Javascript support allows updating other elements of the page from the frame response Microsoft introduced the XmlDocument and XMLHTML objects which are used to make asynchronous requests directly from JavaScript – Other browsers followed this path – Most browsers now name the object XMLHttpRequest

The Application The example application uses the customer information part of the popcorn application As the user enters the zip code information, a request for the corresponding city and state will be made to the server If successful, the information will be filled in the text widgets

The Form Document The trigger for the request is a blur event on the zip code widget this.value is used by the handler to get the zip code value entered All relevant widgets have the id attribute set for easy access in the JavaScript

The Request Phase Two functions – blur event handler – Response processor An XMLHttpRequest object is used to create the request A callback is a function called when a response is received – Function receivePlace is the callback – The function name is assigned to a property of XMLHttpRequest The open method sets up the request – Method parameter, either “GET” or “POST” – URL parameter with zip code in the URL – A parameter signifying asynchronous or not The send method sends the request The getPlace method implements this

The Response Document The response from the server is created by looking up the zip code – A local hash of zip codes is used for simplicity A string with the city and state is sent as the response The example is in PHP

The Receiver Phase The function that parses the response must have access to the XMLHttpRequest object This cannot be global since there may be multiple outstanding requests at any time The callback becomes an anonymous function which is defined in the getPlace method and keeps references to the XMLHttpRequest object held in a local variable The response handler only acts if the readyState is 4, meaning the response is complete

Cross-Browser Support Older Microsoft browsers uses a different approach to getting the request object Testing the existence of window.XMLHttpRequest differentiates the browsers In the older browsers new ActiveXObject(“Microsoft.XMLHTTP” ) creates the object needed

Rails with Ajax The prototype JavaScript library is integrated into Rails Rails and Ajax have some limitations – Not all elements can be modified, depending on the browser – The div element can be modified Rails and Ajax process – Sequence is triggered – Data is sent asynchronously to an action handler – The action handler creates a response – JavaScript in the browser interprets the response

The Initial Form Document The popcorn example is used here, with the zip code helper The show_form action and document show_form.rhtml are the first contact, providing the form

Triggering Ajax Ruby provides methods to set up triggers for Ajax processing – link_to_remote triggers when a link is activated – observe_field is triggered when a widget is changed Method observe_field – Takes the name of the widget as a first paramater – Several ‘keyword’ parameters :url where to post, often associated with an :action symbol definition :update associated to the id of the elment whose value is to be changed in response :with specifies a parameter for the HTTP request :frequency specifies how often to check :complete, :success, :failure associate with callbacks used depending on the outpcome of the reuqest

Example A special tag is used to introduce JavaScript into a Rails template A method update_city_state is defined as the :complete callback since two fields have to be changed with the response

The Controller The fill_city_state method is added to the controller to handle the asynchronous request The render method is used to create the content of the response since it is simple text