JavaScript & AJAX.

Slides:



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

Asynchronous HTTP request generation in JavaScript (AJAX)
AJAX asynchronous server-client communication. Test.
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.
The Document Object Model (DOM) & Asynchronous Javascript And XML (AJAX) : an introduction UFCEKG-20-2 : Data, Schemas and Applications.
Interactive Web Application with AJAX
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.
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,
Lecture 12 – AJAX SFDV3011 – Advanced Web Development Reference: 1.
Ajax - Part II Communicating with the Server. Learning Objectives By the end of this lecture, you should be able to: – Describe the overview of steps.
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,
Ajax In Action The Journey into Web2.0 Presented by Eric Pascarello.
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)
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.
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 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.
AJAX AJAX Asynchronous JavaScript and XML --- MADHAVI
AJAX – Asynchronous JavaScript And XML By Kranthi Kiran Nuthi CIS 764 Kansas State University.
Internet Technologies #6 REST SOAP AJAX. Agenda  REST  SOAP  AJAX.
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.
1 AJAX. AJAX – Whatzit? Asynchronous (content loading)‏ Javascript (logic & control)‏ And XML (request handling)‏
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. 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.
Understanding XMLHttpRequest
Not a Language but a series of techniques
AJAX AJAX = Asynchronous JavaScript and XML.
CS 371 Web Application Programming
AJAX.
AJAX and REST.
Callback Function function passed as a parameter to another function
XMLHttp Object.
Ajax Internet Engineering Fall 2017 Bahador Bakhshi
Web System & Technology
AJAX (Asynchronous JavaScript and XML.)
CSE 154 Lecture 11: AJAx.
AJAX and JSP ISYS 350.
CSE 154 Lecture 22: AJAX.
ISC440: Web Programming 2 AJAX
JavaScript & jQuery AJAX.
Chengyu Sun California State University, Los Angeles
AJAX CS-422 Dick Steflik.
Intro to Ajax Fred Stluka Jan 25, 2006.
Web Technology Even Sem 2015
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
AJAX Chapters 19, 20.
AJAX and JSP ISYS 350.
Presentation transcript:

JavaScript & AJAX

AJAX Asynchronous JavaScript And XML 讀取動作於背後進行,網頁維持原畫面正常運作。 一旦資料從伺服器讀取後,再更新網頁內容。 Ex: gmail, google maps,…

XMLHttpRequest Object var xmlhttp=new XMLHttpRequest(); Method Description abort() Cancels the current request getAllResponseHeaders() Returns the complete set of http headers as a string getResponseHeader("headername") Returns the value of the specified http header open("method","URL",async,"uname","pswd") method: GET, POST, or PUT URL: a relative or complete URL. async: true (asynchronously) false (synchronously) send(content) Sends the request setRequestHeader("label","value") Adds a label/value pair to the http header to be sent

XMLHttpRequest's Properties Property Description onreadystatechange An event handler for an event that fires at every state change readyState Returns the state of the object: 0 = UNSENT 1 = OPENED 2 = HEADERS_RECEIVED 3 = LOADING 4 = DONE responseText Returns the response as a string responseXML Returns the response as XML. This property returns an XML document object. status Returns the status as a number (e.g. 404 for "Not Found" or 200 for "OK") statusText Returns the status as a string (e.g. "Not Found" or "OK") Reference: http://web5.w3.org/TR/XMLHttpRequest/

menu.xml <?xml version="1.0" encoding="UTF-8" ?> <menu> <item> <url>http://www.ncnu.edu.tw/</url> <text>NCNU</text> </item> <url>http://www.im.ncnu.edu.tw/</url> <text>暨大資管</text> <url>https://webmail.ncnu.edu.tw/</url> <text>暨大 Web Mail</text> <url>http://rent.im.ncnu.edu.tw/</url> <text>暨居蟹</text> </menu>

var xmlhttp=new XMLHttpRequest(); window var xmlhttp=new XMLHttpRequest(); window.onload = function() { try { xmlhttp.open("GET", "menu.xml", true); xmlhttp.onreadystatechange=rsChange; xmlhttp.send(null); } catch(e) { alert(e.message); } function rsChange() { if (xmlhttp.readyState==4) { var vmenu=document.getElementById("vmenu"); var xmenu=xmlhttp.responseXML; var itemArr = xmenu.getElementsByTagName("item"); for (var i=0;i<itemArr.length;i++) { var url=itemArr[i].getElementsByTagName("url")[0].firstChild.nodeValue; var text=itemArr[i].getElementsByTagName("text")[0].firstChild.nodeValue; var li =document.createElement("li"); li.innerHTML='<a href="'+url+'">'+text+'</a>'; vmenu.appendChild(li);

var xmlhttp=new XMLHttpRequest(); window.onload = function() { var url="http://www.cwb.gov.tw/rss/forecast/36_10.xml"; try { xmlhttp.open("GET", url, true); xmlhttp.onreadystatechange=rsChange; xmlhttp.send(null); } catch(e) { alert(e.message); } function rsChange() { if (xmlhttp.readyState==4) { var doc=xmlhttp.responseXML; nantou(doc); function nantou(doc) { var item = doc.getElementsByTagName("item")[0]; var title = item.getElementsByTagName("title")[0].firstChild.nodeValue; var desc = item.getElementsByTagName("description")[0].firstChild.nodeValue; document.getElementById("head").innerHTML = title; document.getElementById("content").innerHTML = desc;

http://www.cwb.gov.tw/rss/forecast/36_10.xml

http://ycchen.im.ncnu.edu.tw/www2011/lab/rsshttp.html http://ycchen.im.ncnu.edu.tw/www2011/lab/rsshttp1.html