AJAX asynchronous server-client communication. Test.

Slides:



Advertisements
Similar presentations
Modern JavaScript Develop And Design Instructor’s Notes Chapter 11– Ajax Modern JavaScript Design And Develop Copyright © 2012 by Larry Ullman.
Advertisements

9. AJAX & RIA. 2 Motto: O! call back yesterday, bid time return. — William Shakespeare.
Javascript AJAX HTML WEB SERVER Asynchronous. AJAX FUNCTIONS.
Using AJAX Galip Aydin, Ahmet Sayar, and Marlon Pierce Community Grids Lab Indiana University.
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.
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.
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.
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.
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)
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.
School of Computing and Information Systems CS 371 Web Application Programming AJAX.
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
AJAX Asynchronous JavaScript & XML A short introduction.
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.
Web Technologies Lecture 7 Synchronous vs. asynchronous.
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.
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.
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?
PHP and AJAX. Servers and Clients For many years we tried to move as much as possible to the server. Weak clients, poor bandwidth, browser compatibility..
1 AJAX. AJAX – Whatzit? Asynchronous (content loading)‏ Javascript (logic & control)‏ And XML (request handling)‏
Javascript AJAX HTML WEB SERVER Asynchronous. Javascript HTML events DOM – document object model browser internal view of html page compute.
JavaScript and Ajax Week 10 Web site:
NCCUCS 軟體工程概論 Lecture 5: Ajax, Mashups April 29, 2014.
JQuery, JSON, AJAX. AJAX: Async JavaScript & XML In traditional Web coding, to get information from a database or a file on the server –make an HTML form.
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.
Introduction to AJAX Pat Morin COMP Outline What is AJAX? – History – Uses – Pros and Cons An XML HTTP Transaction – Creating an XMLHTTPRequest.
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.
Callback Function function passed as a parameter to another function
XMLHttp Object.
AJAX.
Web System & Technology
Introduction to AJAX MIS 3502 Jeremy Shafer Department of MIS
CSE 154 Lecture 11: AJAx.
AJAX and JSP ISYS 350.
Introduction to AJAX MIS 3502 Jeremy Shafer Department of MIS
CSE 154 Lecture 22: AJAX.
AJAX Robin Burke ECT 360.
JavaScript & AJAX.
ISC440: Web Programming 2 AJAX
JavaScript & jQuery AJAX.
Chengyu Sun California State University, Los Angeles
Lecture 12: The Fetch Api and AJAx
AJAX CS-422 Dick Steflik.
Intro to Ajax Fred Stluka Jan 25, 2006.
Web Technology Even Sem 2015
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
AJAX and JSP ISYS 350.
Presentation transcript:

AJAX asynchronous server-client communication

Test

Ajax / AJAX / Web 2.0 Ajax (the word) :: asynchronous web technology AJAX (the acronym) :: Asynchronous Javascript and Xml Web 2.0 :: nonsense word (Tim Berners-Lee, 2006) we’ll refrain from using in this classTim Berners-Lee, 2006

Why AJAX? Provide a desktop like experience over the web Because browsers are powerful enough

Where is AJAX? Google Maps, Mail, &c Flickr Facebook Predictive text searches

Viewing / Debugging AJAX Turn on Firebug Go to the NET tab Load a page web page What you See: – A list of each GET request performed by your browser – What is a browser getting on a traditional website?

Observing AJAX requests Clear the Firebug NET pane Start doing something that causes an AJAX action to happen – Ex: start typing in the Google search bar Watch the NET pane

Parameters Sent

Headers (sent + received)

See the Response

HTTP GET & POST Get – Used by client to request data from the server Post – Used by client to send data to server

The XMLHttpRequest object Makes asynchronous http requests using JS The backbone of AJAX You can receive plain XML, HTML, JSON…what ever you want

Testing Browser Type…. if (window.XMLHttpRequest) { ajax = new XMLHttpRequest(); } else if (window.ActiveXObject) { ajax = new ActiveXObject("Microsoft.XMLHTTP"); }

XMLHttpRequest Methods Open(mode, url, async) – Mode: GET or POST – Url: – Async (true for async, false for sync.) Send(str) – In GET mode, str=NULL – In POST mode, str is name/value pairs that you are posting to the service

Async / Synchronous Synchronous: – JS function hangs until there is a response from the server Async: – Creates the request and continues executing the next bit JS code – Creates listeners that are executed when the server responds – Is the right way to do AJAX requests

XMLHttpRequest Attributes readyState – 0: not initialized – 1: connection established – 2: request received – 3: answer in process – 4: done Status – http status…200: OK, 404: file not found, &c

XMLHttpRequest Properties responseText – Response as plain text responseXml – Response as an object (on which you may use DOM methods) onreadystatechange – Function to call when ready state changes setRequestHeader – Tell the client how to configure the outgoing http headers

GET with XMLHttpRequest var url = ‘ ajax.onreadystatechange=function() { if(ajax.readyState==4) { var disp = document.getElementById('test'); disp.innerHTML=xmlhttp.responseText } } ajax.open("GET",url,true); ajax.send(null);

POST with XMLHttpRequest var mypost = “var1=blah&var2=blahblah”; ajax.onreadystatechange=function() { if(ajax.readyState == 4) { alert(“done”); } }; ajax.open("POST", url, true); ajax.setRequestHeader("Content-Type", "application/x-www-form- urlencoded"); ajax.send(mypost);

In Class Work Create a PHP page that outputs ‘Hello World’ followed by the current time. – (as plan text, no need for,, or Create an HTML/JS page that makes an AJAX (GET) request to the PHP page above – Test for each of the readyStates, writing out to a div on the page the state number + a description of the state. – In state 4, also print out the responseText