1 AJAX. AJAX – Whatzit? Asynchronous (content loading)‏ Javascript (logic & control)‏ And XML (request handling)‏

Slides:



Advertisements
Similar presentations
9. AJAX & RIA. 2 Motto: O! call back yesterday, bid time return. — William Shakespeare.
Advertisements

Asynchronous HTTP request generation in JavaScript (AJAX)
AJAX asynchronous server-client communication. Test.
XMLHttpRequest Object and XML What we should learn in this lesson –What is the XHR object? –How to create the XHR objects? –XHR object properties –XHR.
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.
Internet Applications Spring Review Last week –MySQL –Questions?
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.
CGI and AJAX CS-260 Dick Steflik.
Ajax Basics The XMLHttpRequest Object. Ajax is…. Ajax is not…. Ajax is not a programming language. Ajax is not a programming language. Ajax is a methodology.
PHP and AJAX ISYS 475. AJAX Asynchronous JavaScript and XML: – JavaScript, Document Object Model, Cascade Style Sheet, XML, server-side script such as.Net,
Lecture 12 – AJAX SFDV3011 – Advanced Web Development Reference: 1.
Intro to JavaScript Events. JavaScript Events Events in JavaScript let a web page react to some type of input Many different ways to handle events due.
Ajax - Part II Communicating with the Server. Learning Objectives By the end of this lecture, you should be able to: – Describe the overview of steps.
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.
Ajax. –Asynchronous JavaScript and XML –Umbrella term for technologies that often: Use client-side scripting for layout and formatting Use less than full.
Random Logic l Forum.NET l AJAX Behind the buzz word Forum.NET ● January 23, 2006.
Ajax In Action The Journey into Web2.0 Presented by Eric Pascarello.
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)
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:
SYST Web Technologies SYST Web Technologies AJAX.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
 AJAX – Asynchronous JavaScript and XML  Ajax is used to develop fast dynamic web applications  Allows web pages to be updated asynchronously by transferring.
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.
CHAPTER 8 AJAX & JSON WHAT IS AJAX? Ajax lets you…
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
AJAX – Asynchronous JavaScript And XML By Kranthi Kiran Nuthi CIS 764 Kansas State University.
Internet Technologies #6 REST SOAP AJAX. Agenda  REST  SOAP  AJAX.
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?
JavaScript, Sixth Edition Chapter 11 Updating Web Pages with Ajax.
A New Way To Web Applications Development Tin Htut Htut Naing Oo Myanmar Information Technology.
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.
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.
Understanding XMLHttpRequest
Not a Language but a series of techniques
AJAX AJAX = Asynchronous JavaScript and XML.
CS 371 Web Application Programming
AJAX and REST.
XMLHttp Object.
AJAX.
AJAX (Asynchronous JavaScript and XML.)
CSE 154 Lecture 11: AJAx.
Giuseppe Attardi Università di Pisa
CSE 154 Lecture 22: AJAX.
JavaScript & AJAX.
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
Presentation transcript:

1 AJAX

AJAX – Whatzit? Asynchronous (content loading)‏ Javascript (logic & control)‏ And XML (request handling)‏

AJAX - Really? Set of cross-platform conventions and techniques to load data browser-side, without interfering with the display and behaviour of the existing page Relies on Javascript & the DOM, assumes XHTML & CSS used XMLHttpRequest object in browser

AJAX – Whyzit? Reload content pieces parts of an HTML page) without complete page reload

HTTP Transport with Ajax

Request Processing

XmlHttpRequest Browser object to retrieve content from server page was dished from Need a new such object for each request Uses a callback mechanism when the HTTP request state changes

XmlHttpRequest Methods abort()‏ Aborts current request getAllResponseHeaders()‏ Returns set of HTTP headers as string getResponseHeader( headerName )‏ Return specified HTTP header value open( method, URL, [async, [userName, [password]]] )‏ Specifies the method, URL & other request attributes send( content )‏ Send the request setRequestHeader( label, value )‏ Set an HTTP request header

XmlHttpRequest Properties onreadystatechange -> callback function readystate 0..4 (uninitialized, open, send, receiving, done)‏ responseText = response as string responseXml = response as XML fragment responseBody = response as binary-encoded string status = HTTP response code statusText = status as string

Browser Handling if (window.XMLHttpRequest) // Existing class { xhr = new XMLHttpRequest(); // Firefox, Safari,... } else if (window.ActiveXObject) // ActiveX version { xhr = new ActiveXObject("Microsoft.XMLHTTP"); // I.E. } xhr.onreadystatechange = function() { // instructions to process the response }; xhr.open('GET', ' true); xhr.send(null); // for POST only

Reponse Handling xhr.onreadystatechange = function()‏ { if(xhr.readyState == 4)‏ { if(xhr.status == 200) document.ajax.dyn="Received:" + xhr.responseText; else document.ajax.dyn="Error code " + xhr.status; } }; document.getElementById("zone").innerHTML = "Received:" + xhr.responseText;

Ajax Advantages Bandwidth friendly Better separation of data & presentation Considered a “Rich Internet Application” (RIA)‏ a.k.a. Part of Web

Ajax Issues Browser integration Back-button Bookmark ease Javascript enabled Reponse time concerns Reliance on Javascript & DOM Web analytics

Ajax Libraries Dojo Mochikit (Google)‏ Mochikit Prototype YUI ExtJS jQuery

AJAX with CodeIgniter Tutorial … littlebrain.org/2008/05/27/codeigniter-and- ajax-using-jquery-tutorial/ Another … code-igniter-and-jquery-ajax-tutorial/ code-igniter-and-jquery-ajax-tutorial/ Another … -aj-codeigniter/ Library … codeigniter.com/wiki/AJAX_for_CodeIgniter/ More … choosedaily.com/1052/9-ways-to- integrate-ajax-with-codeigniter/

Dojo AJAX Example function hello() { // ➁ dojo.xhrGet( { // ➂ // The following URL must match that used to test the server. url: " handleAs: "text", // choose this wisely timeout: 5000, // Time in milliseconds // The LOAD function will be called on a successful response. load: function(response, ioArgs) { // ➃ dojo.byId("cargo").innerHTML = response; // ➄ return response; // ➅ }, // The ERROR function will be called in an error case. error: function(response, ioArgs) { // ➃ console.error("HTTP status code: ", ioArgs.xhr.status); // ➆ return response; // ➅ } }); }

DOJO AJAX in Practice var kw = { url: "myprogram.php", load: function(data){ dojo.byId('myBox').value = data; }, error: function(data){ console.debug("An error occurred: ", data); }, timeout: 2000, form: "myForm" }; dojo.xhrGet(kw);

JSON vs XML {"menu": { "id": "file", "value": "File", "popup": { "menuitem": [ {"value": "New", "onclick": "CreateNewDoc()"}, {"value": "Open", "onclick": "OpenDoc()"}, {"value": "Close", "onclick": "CloseDoc()"} ] } }} { name : value, … }

JSON for Data Exchange Built-into PHP... $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}'; $obj = json_decode($json); $obj->a … $d = array('foo' => 'bar', 'baz' => 'long'); echo json_encode($d); … {"foo":"bar","baz":"long"} p.s. - Also Built into PHP... $obj = (object)array( "assoc" => array("cow"=>"moo"), "object" => (object)array("cat"=>"miao"), ); $obj = false; foreach ($array as $akey => $aval) { $obj -> {$akey} = $aval; } $array = get_object_vars($obj);