06/10/2015AJAX 1. 2 Introduction All material from www.w3schools.com AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.

Slides:



Advertisements
Similar presentations
6/3/2015eBiquity1 Tutorial on AJAX Anubhav Kale (akale1 AT cs DOT umbc DOT edu)
Advertisements

AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 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,
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
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Lecture 12 – AJAX SFDV3011 – Advanced Web Development Reference: 1.
AJAX By Steven Hernandez Research Analyst NIATEC.
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
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.
Random Logic l Forum.NET l AJAX Behind the buzz word Forum.NET ● January 23, 2006.
AJAX (also known as: XMLHTTP, Remote Scripting, XMLHttpRequest, etc.) Matt Warden.
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.
Fall 2006 Florida Atlantic University Department of Computer Science & Engineering COP 4814 – Web Services Dr. Roy Levow Part 2 – Ajax Fundamentals.
Ajax XMod for Dummies Building DNN Ajax Modules Without Programming Dave McMullen SoCal DNN Users Group 2/7/07 –
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
AJAX stands for Asynchronous JavaScript And XML. AJAX is a type of programming made popular in 2005 by Google (with Google Suggest). AJAX is not a new.
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.
AJAX Asynchronous JavaScript and XML 1. AJAX Outline What is AJAX? Benefits Real world examples How it works 2.
SE-2840 Dr. Mark L. Hornick 1 Introduction to Ajax Asynchronous Javascript And XML.
CHAPTER 13 COMMUNICATING WITH AJAX. LEARNING OBJECTIVES AJAX, which stands for Asynchronous JavaScript and XMLprovides a way for a browser to send and.
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.
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.
JavaScript & Introduction to AJAX
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?
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.
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 SUBMITTED BY NITIN RAMANI C.S.E 3 rd Y 5 th S R.N CS SUBMITTED TO PRO. PUSHPARAJ PATEL SIR.
Open Solutions for a Changing World™ Eddy Kleinjan Copyright 2005, Data Access WordwideNew Techniques for Building Web Applications June 6-9, 2005 Key.
Introduction to AJAX Pat Morin COMP Outline What is AJAX? – History – Uses – Pros and Cons An XML HTTP Transaction – Creating an XMLHTTPRequest.
What is AJAX ? Asynchronous Javascript and XML.
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
XMLHttp Object.
AJAX.
Web System & Technology
AJAX (Asynchronous JavaScript and XML.)
CSE 154 Lecture 11: AJAx.
CSE 154 Lecture 22: AJAX.
NMD202 Web Scripting Week9.
ISC440: Web Programming 2 AJAX
JavaScript & jQuery AJAX.
Chengyu Sun California State University, Los Angeles
AJAX CS-422 Dick Steflik.
DR. JOHN ABRAHAM PROFESSOR UTPA
Web Technology Even Sem 2015
Software Engineering for Internet Applications
Presentation transcript:

06/10/2015AJAX 1

2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating an AJAX app AJAX workshop

AJAX 3 AJAX – the basics AJAX stands for Asynchronous JavaScript And XML Based on JavaScript and HTTP requests AJAX is a type of programming made popular in 2005 by Google (with Google Suggest) AJAX is not a new programming language, but a new way to use existing standards AJAX is good for creating better, faster, and more user-friendly web applications

AJAX 4 Prerequisites HTML / XHTML JavaScript Knowledge of XML and CSS useful too

AJAX 5 How AJAX works With AJAX, your JavaScript can communicate directly with the server, using the JavaScript XMLHttpRequest object. With this object, your JavaScript can trade data with a web server, without reloading the page AJAX uses asynchronous data transfer (HTTP requests) between the browser and the web server, allowing web pages to request small bits of information from the server instead of whole pages. The AJAX technique makes Internet applications smaller, faster and more user-friendly. AJAX is a browser technology independent of web server software

AJAX 6 ‘Old’ way of getting/ sending data In traditional JavaScript coding, to fetch or send information to or from a database or a file on webserver requires making an HTML form and GET or POST data to the server User clicks "Submit" button to send/get the information, waits for the server to respond, then a complete new page loads with results Since server returns a new page each time user submits input, traditional web apps can run slowly and tend to be less user-friendly

AJAX 7 AJAX Uses HTTP Requests AJAX means JavaScript communicates directly with server, using JavaScript XMLHttpRequest object With an HTTP request, web page can make a request to, and get a response from a web server - without reloading the entire page The user remains on same page Does not notice that scripts request pages, or send data to a server in the background Greater transparency – better user experience

Dec 2007AJAX 8 The XMLHttpRequest Object By using the XMLHttpRequest object, a web developer can update a page with data from the server after the page has loaded AJAX was made popular in 2005 by Google (with Google Suggest). Google Suggest uses the XMLHttpRequest object to create a very dynamic web interface: When you start typing in Google's search box, a JavaScript sends the letters off to a server and the server returns a list of suggestions Google Suggest The XMLHttpRequest object is supported in Internet Explorer 5.0+, Safari 1.2, Mozilla 1.0 / Firefox, Opera 8+, and Netscape 7.

AJAX 9 Your First AJAX Application To understand how AJAX works, we will create a small AJAX application First, we are going to create a standard HTML form with two text fields: username and time The username field will be filled in by the user and the time field will be filled in using AJAX. The HTML file will be named "testAjax.htm See next slide

AJAX 10 HTML form below has no submit button Name: Time:

AJAX 11 AJAX - Browser Support The keystone of AJAX is the XMLHttpRequest object Different browsers use different methods to create the XMLHttpRequest object We don’t know which browser any user may use Internet Explorer uses an ActiveXObject, while other browsers uses the built-in JavaScript object called XMLHttpRequest To create this object, and deal with different browsers, we are going to use a "try and catch" statement

function ajaxFunction() { var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } } Script creates variable Comments Warning for user if all browsers fail IE can use 2 types of ActiveXObjects

Dec 2007AJAX 13 Code needed to make AJAX run Tries to create the XMLHttpRequest object Check non-IE browsers first If the test fails, code first tries newer then older IE versions Returns error message for very old browsers Can be cut and paste into your AJAX page

Dec 2007AJAX 14 The XMLHttpRequest object Has 3 important properties – onreadystatechange – readyState – responseText The onreadystatechange property stores the function that will process the response from a server

Dec 2007AJAX 15 readyState The readyState property holds the status of the server's response. We can use this to execute the onreadystatechange function Possible values for the readyState property: – 0 The request is not initialized – 1 The request has been set up – 2 The request has been sent – 3 The request is in process – 4 The request is complete

Dec 2007AJAX 16 responseText The data sent back from the server can be retrieved with the responseText property. In our code, we will set the value of our "time" input field equal to responseText

Dec 2007AJAX 17 Here we test the server for response xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { document.myForm.time.value=xmlHttp.responseText; }

Dec 2007AJAX 18 Sending a request to a server To send off a request to the server, we use the open() method and the send() method The open() method takes three arguments – The first argument defines which method to use when sending the request (GET or POST) – The second argument specifies the URL of the server-side script – The third argument specifies that the request should be handled asynchronously (true or false) The send() method sends the request off to the server

Dec 2007AJAX 19 When to send the request We want to do this when the user releases a key after typing their name Name: Time: Calls our function after key released

Dec 2007AJAX 20 Forming a changing server-side file We will fetch the time from our server Use php to deal with time request Simple server-side file

Dec 2007AJAX 21 Fetching the time We fetch time from a remote server’s php ajaxtest.php Place that in the code Save the file as html Place on your web server in same directory as php file Bingo – page works (only with IE just now)

function ajaxFunction() { var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { document.myForm.time.value=xmlHttp.responseText; } xmlHttp.open("GET","ajaxtest.php",true); xmlHttp.send(null); } Name: <input type="text" onkeyup="ajaxFunction();" name="username" /> Time:

Dec 2007AJAX 23 See our AJAX in action Works well in Mozilla IE is a bit sketchy

Dec 2007AJAX 24 Conclusion AJAX extends the usefulness of web apps Saves entire pages reloading Gives greater transparency to users Data loads ‘in the background’ Uses existing technologies Is becoming very popular

Dec 2007AJAX 25 References news/article.php/ news/article.php/