CHAPTER 13 COMMUNICATING WITH AJAX. LEARNING OBJECTIVES AJAX, which stands for Asynchronous JavaScript and XMLprovides a way for a browser to send and.

Slides:



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

JQUERY/AJAX ALIREZA KHATAMIAN DELARAM YAZDANSEPAS.
AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 2006.
Multiple Tiers in Action
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.
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
1 Ajax. 2 What’s Ajax? AJAX is a combination of a few technologies that has come together in the past few years AJAX used to be an acronym for Asynchronous.
Key question  What are the three standardized core languages used to implement web pages? Write the full name not the abbreviation and describe the “layer”
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.
1 rfXcel Confidential Copyright 2007 Web Technology JavaScript 12/10/07.
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
Instructor, Dr. Khalili Bahram Jeevan Kumar Gogineni.
CHAPTER 14 PROCESSING JAVASCRIPT OBJECT NOTATION (JSON)
Ajax. –Asynchronous JavaScript and XML –Umbrella term for technologies that often: Use client-side scripting for layout and formatting Use less than full.
Asterisk based real-time social chat Advisor : Lian-Jou Tsai Student : Jhe-Yu Wu.
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.
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.
the acronym for Asynchronous JavaScript and XML.
Creating Dynamic Webpages
SYST Web Technologies SYST Web Technologies AJAX.
Ajax for Dynamic Web Development Gregory McChesney.
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.
ASP. ASP is a powerful tool for making dynamic and interactive Web pages An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are.
Web Programming JAvaScript Ajax Programming Web Programming /38.
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…
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.
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.
 AJAX technology  Rich User Experience  Characteristics  Real live examples  JavaScript and AJAX  Web application workflow model – synchronous vs.
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..
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:
NCCUCS 軟體工程概論 Lecture 5: Ajax, Mashups April 29, 2014.
Ajax SUBMITTED BY NITIN RAMANI C.S.E 3 rd Y 5 th S R.N CS SUBMITTED TO PRO. PUSHPARAJ PATEL SIR.
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)
AJAX AJAX = Asynchronous JavaScript and XML.
CS 371 Web Application Programming
AJAX.
AJAX.
Web System & Technology
Introduction to AJAX MIS 3502 Jeremy Shafer Department of MIS
AJAX and JSP ISYS 350.
Introduction to AJAX MIS 3502 Jeremy Shafer Department of MIS
NMD202 Web Scripting Week9.
ISC440: Web Programming 2 AJAX
JavaScript & jQuery AJAX.
MIS JavaScript and API Workshop (Part 3)
AJAX CS-422 Dick Steflik.
Web Technology Even Sem 2015
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
AJAX and JSP ISYS 350.
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
AJAX By Prof. B.A.Khivsara
Presentation transcript:

CHAPTER 13 COMMUNICATING WITH AJAX

LEARNING OBJECTIVES AJAX, which stands for Asynchronous JavaScript and XMLprovides a way for a browser to send and receive requests to a remote server Using AJAX is a three step process: the browser sends a request, receives the response, and then processes the result To perform an AJAX request, JavaScript code will use the XMLHttpRequest object When a page makes an AJAX request, the JavaScript code will specify a JavaScript function which the browser will call when the browser receives a response from the remote server

AJAX AJAX provides a way for JavaScript to send and receive data to and from a server. A good example of the use of AJAX is the Google search engine. When you use Google, the page provides you with suggested queries as you type. As it turns out, each time you type a letter, the site uses AJAX to send your current text to the server, which in turn, sends back the recommended queries. The process is that fast!

THE THREE-STEP AJAX PROCESS

XMLHTTPREQUEST varxmlhttp; function AJAXDemo() { xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = HandleData; xmlhttp.open("GET","quotes.txt", true); xmlhttp.send(); } function HandleData() { if (xmlhttp.readyState==4 &&xmlhttp.status==200) { alert(xmlhttp.responseText); } }

ASYNCHRONOUS OPERATIONS The “A” in AJAX stands for Asynchronous. In general, what that means is that the browser will send a request to the server which in turn, will perform some processing, for which it will “get back” to the page in the future. When we perform asynchronous operations, we do not know how long the operation will take or when the server will get back. In other words, the browser sends a request to the server and the then resumes whatever it was doing. When the server response comes back, the browser will stop what it is doing and will process the response. For this process to work, the browser defines a JavaScript function, called a “callback function,” which the browser will execute when the server response comes in.

GETTING INFORMATION FROM A SCRIPT varxmlhttp; function AJAXDemo() { xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = HandleData; xmlhttp.open("GET","GetTime.php", true); xmlhttp.send(); } function HandleData() { if (xmlhttp.readyState==4 &&xmlhttp.status==200) { alert(xmlhttp.responseText); } }

THE PHP SCRIPT

MOUSEOVER EVENTS DRIVING AJAX REQUESTS var xmlhttp; function AJAXData(DataRequest) { xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = HandleData; xmlhttp.open("GET",DataRequest, true); xmlhttp.send(); } function HandleData() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { alert(xmlhttp.responseText); } }

SUBMITTING DATA TO A REMOTE SCRIPT varxmlhttp; function EchoUppercase(DataString) { xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = HandleData; xmlhttp.open("GET","Echo.php?src="+DataString, true); xmlhttp.send(); } function HandleData() { if (xmlhttp.readyState==4 &&xmlhttp.status==200) { alert(xmlhttp.responseText); } } Type text: Click Here

GETTING XML DATA varxmlhttp; function GetXMLData(DataString) { xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = HandleData; xmlhttp.open("GET",DataString, true); xmlhttp.send(); } function HandleData() { if (xmlhttp.readyState==4 &&xmlhttp.status==200) { varxmlDoc = xmlhttp.responseText; alert(xmlDoc); } }

REAL WORLD: STATES HINT varxmlhttp; function GetState(DataString) { xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = HandleData; xmlhttp.open("GET","State.php?src="+DataString, true); xmlhttp.send(); } function HandleData() { if (xmlhttp.readyState==4 &&xmlhttp.status==200) { document.getElementById('hint').innerHTML = xmlhttp.responseText; } } State:

REAL WORLD: SIMPLE PHP SCRIPT

SUMMARY To improve web-page processing capabilities and functionality, developers can take advantage of the fact that JavaScript can send data and request content to or from a remote server. Asynchronous JavaScript and XML, or AJAX, is a technique that developers can use to perform JavaScript-based interactions with a server.