Web Technology Even Sem 2015

Slides:



Advertisements
Similar presentations
AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 2006.
Advertisements

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.
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,
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.
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. –Asynchronous JavaScript and XML –Umbrella term for technologies that often: Use client-side scripting for layout and formatting Use less than full.
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.
the acronym for Asynchronous JavaScript and XML.
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.
Web Programming JAvaScript Ajax Programming Web Programming /38.
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.
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.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
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:
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)
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
XMLHttp Object.
Ajax Internet Engineering Fall 2017 Bahador Bakhshi
AJAX.
Web System & Technology
AJAX (Asynchronous JavaScript and XML.)
CSE 154 Lecture 11: AJAx.
AJAX and JSP ISYS 350.
Web-Technology Lecture 10.
CSE 154 Lecture 22: AJAX.
NMD202 Web Scripting Week9.
JavaScript & AJAX.
ISC440: Web Programming 2 AJAX
JavaScript & jQuery AJAX.
Exchange data interface
AJAX CS-422 Dick Steflik.
Advanced Concepts and AJAX
AJAX and JSP ISYS 350.
PHP and JSON Topics Review JSON.
What is AJAX? AJAX is a developer's dream, because you can:
Communicating with the Server
AJAX By Prof. B.A.Khivsara
Software Engineering for Internet Applications
Presentation transcript:

Web Technology Even Sem 2015 Unit-III AJAX Hammad Lari Computer Science Department www.ncs504wt.wordpress.com

What is AJAX? AJAX = Asynchronous JavaScript and XML. AJAX is a technique for creating fast and dynamic web pages. AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page. Classic web pages, (which do not use AJAX) must reload the entire page if the content should change. Examples of applications using AJAX: Google Maps, Gmail, Youtube, and Facebook tabs.

How AJAX Works

AJAX Example <!DOCTYPE html> <html> <head> <script> function loadXMLDoc() { .... AJAX script goes here ... } </script> </head> <body> <div id="myDiv"><h2>Let AJAX change this text</h2></div> <button type="button" onclick="loadXMLDoc()">Change Content</button> </body> </html>

The XMLHttpRequest Object The keystone of AJAX is the XMLHttpRequest object. All modern browsers support the XMLHttpRequest object (IE5 and IE6 use an ActiveXObject). The XMLHttpRequest object is used to exchange data with a server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page. Syntax for creating an XMLHttpRequest object: variable=new XMLHttpRequest(); Old versions of Internet Explorer (IE5 and IE6) uses an ActiveX Object: variable=new ActiveXObject("Microsoft.XMLHTTP");

Example xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } xmlhttp.open("GET","ajax_info.txt",true); xmlhttp.send(); </script> </head> <body> <div id="myDiv"><h2>Let AJAX change this text</h2></div> <button type="button" onclick="loadXMLDoc()">Change Content</button> </body> </html> <!DOCTYPE html> <html> <head> <script> function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

Result

Send a Request To a Server The XMLHttpRequest object is used to exchange data with a server. To send a request to a server, we use the open() and send() methods of the XMLHttpRequest object: xmlhttp.open("GET","ajax_info.txt",true); xmlhttp.send(); Method Description open(method,url,async) Specifies the type of request, the URL, and if the request should be handled asynchronously or not. method: the type of request: GET or POST url: the location of the file on the server async: true (asynchronous) or false (synchronous) send(string) Sends the request off to the server. string: Only used for POST requests

The onreadystatechange event When a request to a server is sent, we want to perform some actions based on the response. The onreadystatechange event is triggered every time the readyState changes. The readyState property holds the status of the XMLHttpRequest. Three important properties of the XMLHttpRequest object: Property Description onreadystatechange Stores a function (or the name of a function) to be called automatically each time the readyState property changes readyState Holds the status of the XMLHttpRequest. Changes from 0 to 4: 0: request not initialized  1: server connection established 2: request received  3: processing request  4: request finished and response is ready status 200: "OK" 404: Page not found

Retreive Contents from a PHP file <html> <head> <script> function showHint(str) {     if (str.length == 0) {          document.getElementById("txtHint").innerHTML = "";         return;     } else {         var xmlhttp = new XMLHttpRequest();         xmlhttp.onreadystatechange = function() {             if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {                 document.getElementById("txtHint").innerHTM L = xmlhttp.responseText;             }         }         xmlhttp.open("GET", "gethint.php?q=" + str, true);         xmlhttp.send();     } } </script> </head> <body> <p><b>Start typing a name in the input field below:</b></p> <form>  First name: <input type="text" onkeyup="showHint(this.value)"> </form> <p>Suggestions: <span id="txtHint"></span></p> </body> </html>

<?php // Array with names $a[] = "Anna"; $a[] = "Brittany"; $a[] = "Cinderella"; $a[] = "Diana"; $a[] = "Eva"; $a[] = "Fiona"; $a[] = "Gunda"; $a[] = "Hege"; $a[] = "Inga"; $a[] = "Johanna"; $a[] = "Kitty"; $a[] = "Linda"; $a[] = "Nina"; $a[] = "Ophelia"; $a[] = "Petunia"; $a[] = "Amanda"; $a[] = "Raquel"; $a[] = "Cindy"; $a[] = "Doris"; $a[] = "Eve"; $a[] = "Evita"; $a[] = "Sunniva"; $a[] = "Tove"; $a[] = "Unni"; $a[] = "Violet"; $a[] = "Liza"; $a[] = "Elizabeth"; $a[] = "Ellen"; $a[] = "Wenche"; $a[] = "Vicky"; // get the q parameter from URL $q = $_REQUEST["q"]; $hint = ""; // lookup all hints from array if $q is different from ""  if ($q !== "") {     $q = strtolower($q);     $len=strlen($q);     foreach($a as $name) {         if (stristr($q, substr($name, 0, $len))) {             if ($hint === "") {                 $hint = $name;             } else {                 $hint .= ", $name";             }         }     } } // Output "no suggestion" if no hint was found or output correct values  echo $hint === "" ? "no suggestion" : $hint; ?>

Try AJAX with 1.Database 2.ASP 3.XML