Lecture 9: AJAX, Javascript review..  AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype,

Slides:



Advertisements
Similar presentations
JavaScript and AJAX Jonathan Foss University of Warwick
Advertisements

9. AJAX & RIA. 2 Motto: O! call back yesterday, bid time return. — William Shakespeare.
6/3/2015eBiquity1 Tutorial on AJAX Anubhav Kale (akale1 AT cs DOT umbc DOT edu)
AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 2006.
WHAT IS AJAX? Zack Sheppard [zts2101] WHIM April 19, 2011.
Does Ajax suck? CS575 Spring 2007 Chanwit Suebsureekul.
1 JavaScript & AJAX CS , Spring JavaScript.
Using AJAX Galip Aydin, Ahmet Sayar, and Marlon Pierce Community Grids Lab Indiana University.
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
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.
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.
JavaScript & jQuery the missing manual Chapter 11
CS 4720 RESTfulness and AJAX CS 4720 – Web & Mobile Systems.
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.
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.
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.
Posting XML Data From the Client to a Server Eugenia Fernandez IUPUI.
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.
Telerik Software Academy ASP.NET Web Forms Telerik Software Academy ASP.NET Web Forms.
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:
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.
SE-2840 Dr. Mark L. Hornick 1 Introduction to Ajax Asynchronous Javascript And XML.
AJAX. Ajax  $.get  $.post  $.getJSON  $.ajax  json and xml  Looping over data results, success and error callbacks.
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 – 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.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
1 AJAX. AJAX – Whatzit? Asynchronous (content loading)‏ Javascript (logic & control)‏ And XML (request handling)‏
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript, Sixth Edition Chapter 11 Updating Web Pages with Ajax.
JavaScript and Ajax Week 10 Web site:
NCCUCS 軟體工程概論 Lecture 5: Ajax, Mashups April 29, 2014.
AJAX. Objectives Understand and apply AJAX Using AJAX in DOJO library.
National College of Science & Information Technology.
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.
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.
CSE 154 Lecture 11: AJAx.
CSE 154 Lecture 22: AJAX.
JavaScript & jQuery AJAX.
AJAX CS-422 Dick Steflik.
Intro to Ajax Fred Stluka Jan 25, 2006.
DR. JOHN ABRAHAM PROFESSOR UTPA
Chengyu Sun California State University, Los Angeles
Introduction to AJAX and JSON
Chengyu Sun California State University, Los Angeles
Presentation transcript:

Lecture 9: AJAX, Javascript review.

 AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype, Scriptaculous, etc.  Javascript Review  All coding.  Changing the behavior of links by file extension.  Moving and fading page elements.  Changing the page based on the time of day.

 Ordinary (Synchronous) page loading:  Browse to one page.  Click a link.  New page pops up in its entirety.  The old page is lost.  Asynchronous loading:  Event triggered (not necessarily a link click).  New page data loaded.  Alteration made to the current page.  The current page is retained.  Asynchronous browsing is accomplished using a popular technique called AJAX: Asynchronous Javascript and XML.

 Recall the list of standard Javascript classes.  Most classes were named intuitively, e.g.:  Math  Date  Number  But there was also one class called XMLHttpRequest.  This is the class used with AJAX.  It instructs the browser to create an “HTTP Request” (i.e. request a new page) and return XML (or any sort of data). ▪ The result is populated with the contents of the page we asked the browser to request. ▪ XHTML 1.0 is valid XML (which is why we preferred using it to HTML 4.0). ▪ The contents can either be returned as a raw String of code or as a DOM tree node. ▪ The String is parsed using the String class or inserted into the page with document.write(). ▪ The DOM node can be appended into the page using appendChild() or insertBefore().  What can this be used for?  Form validation is usually performed twice: once on the client-side for user convenience and once on the server-side for actual security.  Using AJAX, we can validate once on the server side and return the results without leaving the current page: convenient and secure, and it saves effort!  We can retrieve content from the server (e.g. user preferences) only when required, avoiding burdening users who don’t make use of that feature with the overhead.  We can selectively load only the parts of a page that we need, without needing to reload the whole page.  We can make navigation appear smoother, more like a desktop application.

 Called using objects and constructors; i.e. var xhr = new XMLHttpRequest();  Two useful (in fact, required) functions:  open(method, url, asynchronous): connects to the specified url. Method is either “GET” or “POST”. Asynchronous is true/false; if false, the function will not return until the page is loaded. (AJAX always uses true).  send(postdata): Sends POST variables (such as form data) to the server. Postdata is a string. If method is GET, call send(null); GET requests do not include POST variables.  Five variables:  status: Once the request completes, the numeric status code sent back by the server (i.e. 200 (OK), 404 (Not Found), 500 (Internal Server Error)).  responseText: The raw text of the response.  responseXml: A DOM node representing the response.  readyState: The current state of the connection (connecting, waiting for response, received, etc. 4 means received).  onreadystatechange: An event which fires when the state of the connection changes. Can be used to determine when an asynchronous request completes. Manipulate this by passing the name of a function, like any other event.  Example usage:  var xhr = new XMLHttpRequest();  xhr.onreadystatechange = updateXHR;  xhr.open(“GET”, “ true);  xhr.send(null);//Necessary, but always passed null for GET requests.  function updateXHR() { ▪ if (xhr.readyState == 4) ▪ alert(xhr.responseText);  }

 Use AJAX, but do not rely on AJAX.  Some users may not have Javascript enabled.  Some may have Javascript enabled and may not support XMLHttpRequest  IE6 requires a different means of invocation.  You can check for this and use it, but the point still stands that not all browsers may support AJAX.  When using advanced web development features, practice a philosophy known as graceful degradation.  Do not rely on advanced features.  Use them to enhance the user experience, not enable it.  Allow the user to perform all possible actions without relying on the feature.  AJAX often degrades to normal hyperlinks or form behavior.

 There are several libraries which make AJAX easier to use:  Prototype Prototype  Scriptaculous Scriptaculous  jQuery jQuery  These also allow you to create interesting dynamic effects on your pages.  Use of these frameworks is outside of the scope of this course, but they’re intuitive.

 Final Lecture: putting it all together.  Design of a fully interactive website in its entirety, from concept to completed design.

A Nonprofit Organization of New Jersey, USA