15-Jun-15 Ajax with XML. Displaying theAjax response Here is the previous code for dealing with a non-XML response: function alertContents(http_request)

Slides:



Advertisements
Similar presentations
9. AJAX & RIA. 2 Motto: O! call back yesterday, bid time return. — William Shakespeare.
Advertisements

6/3/2015eBiquity1 Tutorial on AJAX Anubhav Kale (akale1 AT cs DOT umbc DOT edu)
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
Javascript and AJAX Willem Visser RW334. Overview Javascript jQuery AngularJS AJAX.
Some HTTP Examples. A utility which shows all data from incoming requests is here: It is.
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,
 2002 Prentice Hall. All rights reserved. 1 Chapter 6 – Introduction to the Common Gateway Interface (CGI) Outline 6.1 Introduction 6.2 Client and Web.
AJAX asynchronous server-client communication. Test.
How the web works: HTTP and CGI explained
Multiple Tiers in Action
Before we get started Tonight, an optional lab Groups? Other Questions? Tonight, an optional lab Groups? Other Questions?
AJAX (Asynchronous JavaScript and XML) Amit Jain CS 590 – Winter 2008.
14-Jul-15 Ajax. The hype Ajax (sometimes capitalized as AJAX) stands for Asynchronous JavaScript And XML Ajax is a technique for creating “better, faster,
Using AJAX Galip Aydin, Ahmet Sayar, and Marlon Pierce Community Grids Lab Indiana University.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Chapter 4 Mixing PHP and HTML  In this chapter, you’ll learn how to do the following: -Recognize and use the different kinds of PHP start and end tags.
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
INT222 – Internet Fundamentals Weekly Notes: AJAX and Canvas 1.
Agenda Web Development Chapter 7 Review Class Discussion Issues.
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.
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.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
CSC 2720 Building Web Applications Getting and Setting HTTP Headers (With PHP Examples)
AJAX and Java ISYS 350. AJAX Asynchronous JavaScript and XML: – Related technologies: JavaScript, Document Object Model, XML, server-side script such.
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
CIS 375—Web App Dev II DOM. 2 Introduction to DOM The XML Document ________ Model (DOM) is a programming interface for XML documents. It defines the way.
Ajax - 1h. AJAX IS: A browser technology A technology that uses only JavaScript in the browser page A very efficient way of updating information A way.
OWL Jan How Websites Work. “The Internet” vs. “The Web”?
J.Holvikivi 1 Ajax & scripts Jaana Holvikivi Metropolia.
Lecture 9: AJAX, Javascript review..  AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype,
Netprog 2002 CGI Programming1 CGI Programming CLIENT HTTP SERVER CGI Program http request http response setenv(), dup(), fork(), exec(),...
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:
AJAX Asynchronous JavaScript & XML A short introduction.
Jan 2001C.Watters1 World Wide Web and E-Commerce Client Side Processing.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Summer 2007 Florida Atlantic University Department of Computer Science & Engineering COP 4814 – Web Services Dr. Roy Levow Part 1 – Introducing Ajax.
SE-2840 Dr. Mark L. Hornick 1 Introduction to Ajax Asynchronous Javascript And XML.
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.
AJAX AJAX Asynchronous JavaScript and XML --- MADHAVI
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.
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 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:
Web Services Essentials. What is a web service? web service: software functionality that can be invoked through the internet using common protocols like.
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 Dr. Reda Salama. The hype Ajax (sometimes capitalized as AJAX) stands for Asynchronous JavaScript And XML Ajax is a technique for creating “better,
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.
JavaScript and Ajax (Ajax Tutorial)
CSE 154 Lecture 11: AJAx.
Not a Language but a series of techniques
AJAX AJAX = Asynchronous JavaScript and XML.
AJAX and REST.
XMLHttp Object.
AJAX.
CSE 154 Lecture 11: AJAx.
CSE 154 Lecture 22: AJAX.
JavaScript & jQuery AJAX.
Ajax with XML 23-Feb-19.
Ajax with XML 27-Feb-19.
Chengyu Sun California State University, Los Angeles
AJAX CS-422 Dick Steflik.
Presentation transcript:

15-Jun-15 Ajax with XML

Displaying theAjax response Here is the previous code for dealing with a non-XML response: function alertContents(http_request) { if (http_request.readyState == 4) { if (http_request.status == 200) { alert(http_request.responseText); } else { alert('There was a problem with the request.'); } } }

Doing it with XML Here’s an XML file named test.xml : I'm a test. function alertContents(http_request) { if (http_request.readyState == 4) { if (http_request.status == 200) { var xmldoc = http_request.responseXML; var root_node = xmldoc.getElementsByTagName('root').item(0); alert(root_node.firstChild.data); } else { alert('There was a problem with the request.'); } } }

responseText and responseXML The Content-Type in the header tells the type of server response For non-XML, you can use text/html or text/plain For sending XML, it's better to use text/xml When the server sends text/xml, the browser parses it, creates an XML DOM tree, and places this tree in the responseXML object The XML is also available in the responseText object, but it you use this you will have to parse it yourself

HTML DOM vs. XML DOM The DOM for the web page represents HTML The DOM for the XML represents the server's response They have the same methods!

Sending XML to the server The server is really good at handling name-value pairs If you want to send XML... It pretty much has to be sent as POST XML gets long very quickly All those special characters need to be URL-encoded You have to setRequestHeader("Content-Type", "text/xml") The server doesn't have DOM trees--you will have to parse the XML yourself Bottom line: Sending XML to the server is too much work!

XML notes The XML response object supports very complete XML DOM processing The response header must include: Content-Type: text/xml or IE will throw an “Object expected” JavaScript error Cache-Control: no-cache or the response will be cached and the request will never be resubmitted For some browsers you may need to do request.overrideMimeType('text/xml'); In Firefox, this will give an error if the response isn’t valid XML

The End