Ajax with XML 23-Feb-19.

Slides:



Advertisements
Similar presentations
Javascript and AJAX Willem Visser RW334. Overview Javascript jQuery AngularJS AJAX.
Advertisements

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)
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.
WHAT IS AJAX? Zack Sheppard [zts2101] WHIM April 19, 2011.
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.
INT222 – Internet Fundamentals Weekly Notes: AJAX and Canvas 1.
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,
Lecture 12 – AJAX SFDV3011 – Advanced Web Development Reference: 1.
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.
Lecture 9: AJAX, Javascript review..  AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype,
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.
Web Technologies Lecture 3 Web forms. HTML5 forms A component of a webpage that has form controls – Text fields – Buttons – Checkboxes – Range controls.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
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 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
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?
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.
XML DOM Week 11 Web site:
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.
What’s Really Happening
National College of Science & Information Technology.
Unit 4 Representing Web Data: XML
CSE 154 Lecture 11: AJAx.
Not a Language but a series of techniques
AJAX AJAX = Asynchronous JavaScript and XML.
How does it work ?.
AJAX and REST.
XMLHttp Object.
AJAX.
CSE 154 Lecture 11: AJAx.
AJAX and JSP ISYS 350.
CSE 154 Lecture 22: AJAX.
AJAX Robin Burke ECT 360.
Asynchronous Javascript And XML
ISC440: Web Programming 2 AJAX
JavaScript & jQuery AJAX.
Ajax with XML 27-Feb-19.
Ajax 28-Feb-19.
Chengyu Sun California State University, Los Angeles
Kevin Harville Source: Webmaster in a Nutshell, O'Rielly Books
Ajax 6-Apr-19.
AJAX CS-422 Dick Steflik.
PHP Forms and Databases.
Chengyu Sun California State University, Los Angeles
Client-Server Model: Requesting a Web Page
Chengyu Sun California State University, Los Angeles
AJAX and JSP ISYS 350.
Presentation transcript:

Ajax with XML 23-Feb-19

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: <?xml version="1.0" ?> <root> I'm a test. </root> 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