Not a Language but a series of techniques

Slides:



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

9. AJAX & RIA. 2 Motto: O! call back yesterday, bid time return. — William Shakespeare.
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,
AJAX asynchronous server-client communication. Test.
Using AJAX Galip Aydin, Ahmet Sayar, and Marlon Pierce Community Grids Lab Indiana University.
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.
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,
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Lecture 12 – AJAX SFDV3011 – Advanced Web Development Reference: 1.
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.
XMLHttpRequest Object When Microsoft Internet Explorer 5.0 introduced a rudimentary level of XML support, an ActiveX library called MSXML was also introduced,
Using Client-Side Scripts to Enhance Web Applications 1.
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)
Fall 2006 Florida Atlantic University Department of Computer Science & Engineering COP 4814 – Web Services Dr. Roy Levow Part 2 – Ajax Fundamentals.
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:
the acronym for Asynchronous JavaScript and XML.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
SE-2840 Dr. Mark L. Hornick 1 Introduction to Ajax Asynchronous Javascript And XML.
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.
Event Handling & AJAX IT210 Web Systems. Question How do we enable users to dynamically interact with a website? Answer: Use mouse and keyboard to trigger.
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
What is AJAX ? Asynchronous Javascript and XML. Not a stand-alone language or technology. It is a technique that combines a set of known technologies in.
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?
Introduction to AJAX MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/4/2016.
JavaScript, Sixth Edition Chapter 11 Updating Web Pages with Ajax.
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.
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.
AJAX AJAX = Asynchronous JavaScript and XML.
CS 371 Web Application Programming
Working with Client-Side Scripting
AJAX and REST.
XMLHttp Object.
AJAX – Asynchronous JavaScript and XML
AJAX.
Web System & Technology
CSE 154 Lecture 11: AJAx.
Predefined Dialog Boxes
CSE 154 Lecture 22: AJAX.
AJAX Robin Burke ECT 360.
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.
Lecture 12: The Fetch Api and AJAx
Intro to Ajax Fred Stluka Jan 25, 2006.
DR. JOHN ABRAHAM PROFESSOR UTPA
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
AJAX Chapters 19, 20.
Presentation transcript:

Not a Language but a series of techniques AJAX Not a Language but a series of techniques Copyright © 2008-2015 - Curt Hill

Web Browser Interaction A web browser has a spiky workload Most of the time it is doing almost nothing When a link is clicked a server request is sent During the latency period it is waiting for the server When server response is complete then it waits again for the user to act Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill Passing the Time When a link is clicked a large state change occurs from one web page to another Pictures may be loaded with subsequent requests Still most of the time the browser doing nothing AJAX is technique to keep the browser busier and incrementally load items while it seems to be idle Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill AJAX Asynchronous JavaScript And XML The idea of AJAX is to incrementally change the content without the dramatic state change A communication is set up between the JavaScript program and the server that does not cause a page reload Small changes without the major reload delay Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill AJAX intent Instead of the vast idle periods do a series of partial updates These are not as significant as a page reload Allow the period while the user is reading the page to do something significant The Asynchronous part of AJAX is the browser is not locked during the partial updates Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill Attractions Makes web applications more responsive Not much new to learn for the web developers Use existing and well understood technology: JavaScript CSS DOM XML Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill Central Object The important JavaScript object varies depending on the browser On IE it is an ActiveX object On most others it is called XMLHttpRequest Both are Host Objects rather than Native Thus the difference in name I will call it HttpRequest for the rest of the presentation Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill Example of creation Here is how to create the object: var httpRqst; if (IE) httpRqst = new window.ActiveXObject( “Microsoft.XMLHTTP”); else httpRqst = new XMLHttpRequest(); The actual code is somewhat more complicated Copyright © 2008-2015 - Curt Hill

Methods and Properties The HttpRequest object has two methods and one property of particular importance: open method send method onreadystatechange property Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill The open method The open method has three parameters and must be executed first First parameter is a string that determines request method Usually GET or POST Usually best to keep in all caps Second parameter is a URL Third parameter is a boolean Whether to operate asynchronously or not Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill Example open Consider: httpRqst.open(“POST”, ”http://my.com/php/my.php”, true); The second parameter must specify exactly the same server as the page that will send the request An alias will violate security Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill The send method Two possibilities If GET is used the data is part of the open string Send sends it but the parameter is null If POST is used, Send carries the data This is used to send the data that will be processed Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill The data to send It has the form of: “key1=val1&key2=val2…” For POST: httpRqst.open(“POST”, ”http://my.com/php/my.php”, true); httpRqst.send(“item=paper&number=10”); Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill Example send with Get Open and send httpRqst.open(“GET”, ”http://my.com/php/my.php? item=paper&number=10”, true); httpRqst.send(null); No blanks, of course Copyright © 2008-2015 - Curt Hill

The onreadystatechange property This is the event handler for when the server responds This should receive a function name Function should be parameterless Leave off the parentheses The function is being connected with the event and not being called Copyright © 2008-2015 - Curt Hill

Example event handler assignment Consider: httpRqst.onreadystatechange = catcher; … function catcher(){ … This is where the response is received However it will receive responses it may not need Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill Checking The event handler needs to check what has happened Two properties to look at: readyState status Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill readyState The possible readyState values include: 0 - uninitialized 1 - loading 2 - loaded 3 - still communicating 4 - complete This is the main one Until it is complete there is nothing to do Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill status The status gives the server status for this request A status of 200 means successful The rest are defined elsewhere but usually indicate some type of failure A status of 404 means the target file was not found A status of 500 means internal server error Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill Now what? Once the request is complete and there was no error, how is it accessed? Two properties contain the results: responseText contains the response as a string responseXML contains it as an XML document Copyright © 2008-2015 - Curt Hill

Copyright © 2008-2015 - Curt Hill FInally We now have the ability to send an HTML request to our server Either synchronously or asynchronously Then process the resulting response Copyright © 2008-2015 - Curt Hill