JavaScript and Ajax (Ajax Tutorial)

Slides:



Advertisements
Similar presentations
6/3/2015eBiquity1 Tutorial on AJAX Anubhav Kale (akale1 AT cs DOT umbc DOT edu)
Advertisements

AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 2006.
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.
JavaScript & jQuery the missing manual Chapter 11
Ruth Betcher Ruth Christie
Lecture 12 – AJAX SFDV3011 – Advanced Web Development Reference: 1.
Server-side Scripting Powering the webs favourite services.
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
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.
Instructor, Dr. Khalili Bahram Jeevan Kumar Gogineni.
Random Logic l Forum.NET l AJAX Behind the buzz word Forum.NET ● January 23, 2006.
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.
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 ( Asynchronous JavaScript + XML ) Information Science and Knowledge Systems: Semantic Web Spring 2006 / Dr. Don Turnbull Presented by David Kim.
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.
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.
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.
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.
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.
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
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.
 AJAX technology  Rich User Experience  Characteristics  Real live examples  JavaScript and AJAX  Web application workflow model – synchronous vs.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
JavaScript and Ajax Week 10 Web site:
JQuery, JSON, AJAX. AJAX: Async JavaScript & XML In traditional Web coding, to get information from a database or a file on the server –make an HTML form.
AJAX. Objectives Understand and apply AJAX Using AJAX in DOJO library.
Ajax SUBMITTED BY NITIN RAMANI C.S.E 3 rd Y 5 th S R.N CS SUBMITTED TO PRO. PUSHPARAJ PATEL SIR.
National College of Science & Information Technology.
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.
Web Programming Language
CSE 154 Lecture 11: AJAx.
Section 6.3 Server-side Scripting
Not a Language but a series of techniques
AJAX AJAX = Asynchronous JavaScript and XML.
JavaScript and Ajax (Internet Background)
CS 371 Web Application Programming
AJAX and REST.
XMLHttp Object.
AJAX.
AJAX.
PHP / MySQL Introduction
Web System & Technology
CSE 154 Lecture 11: AJAx.
CSE 154 Lecture 22: AJAX.
AJAX Robin Burke ECT 360.
ISC440: Web Programming 2 AJAX
JavaScript & jQuery AJAX.
Chengyu Sun California State University, Los Angeles
AJAX CS-422 Dick Steflik.
DR. JOHN ABRAHAM PROFESSOR UTPA
Web Technology Even Sem 2015
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
Presentation transcript:

JavaScript and Ajax (Ajax Tutorial) Week 10 Web site: http://fog.ccsf.edu/~hyip

Ajax Tutorial AJAX stands for Asynchronous JavaScript And XML. AJAX is not a new programming language, but a technique for creating better, faster, and more interactive web applications. With AJAX, your JavaScript can communicate directly with the server, using the JavaScript XMLHttpRequest object. With this object, your JavaScript can trade data with a web server, without reloading the page. AJAX uses asynchronous data transfer (HTTP requests) between the browser and the web server, allowing web pages to request small bits of information from the server instead of whole pages. The AJAX technique makes Internet applications smaller, faster and more user-friendly. AJAX is a browser technology independent of web server software.

Ajax Introducation What You Should Already Know Before you continue you should have a basic understanding of the following: HTML / XHTML JavaScript

Ajax is based on Web Standards AJAX is based on the following web standards: JavaScript XML HTML CSS The web standards used in AJAX are well defined, and supported by all major browsers. AJAX applications are browser and platform independent.

Ajax uses HTTP Requests In traditional JavaScript coding, if you want to get any information from a database or a file on the server, or send user information to a server, you will have to make an HTML form and GET or POST data to the server. The user will have to click the "Submit" button to send/get the information, wait for the server to respond, then a new page will load with the results. Because the server returns a new page each time the user submits input, traditional web applications can run slowly and tend to be less user- friendly. With AJAX, your JavaScript communicates directly with the server, through the JavaScript XMLHttpRequest object With an HTTP request, a web page can make a request to, and get a response from a web server - without reloading the page. The user will stay on the same page, and he or she will not notice that scripts request pages, or send data to a server in the background.

The XMLHttpRequest Object By using the XMLHttpRequest object, a web developer can update a page with data from the server after the page has loaded! AJAX was made popular in 2005 by Google (with Google Suggest). Google Suggest is using the XMLHttpRequest object to create a very dynamic web interface: When you start typing in Google's search box, a JavaScript sends the letters off to a server and the server returns a list of suggestions. (http://www.google.com/webhp?complete=1&hl=en) The XMLHttpRequest object is supported in Internet Explorer 5.0+, Safari 1.2, Mozilla 1.0 / Firefox, Opera 8+, and Netscape 7.

More about the XMLHttpRequest Object Before sending data to the server, we have to explain three important properties of the XMLHttpRequest object. 1. The onreadystatechange Property After a request to the server, we need a function that can receive the data that is returned by the server. The onreadystatechange property stores the function that will process the response from a server. The following code defines an empty function and sets the onreadystatechange property at the same time: xmlHttp.onreadystatechange=function() { // We are going to write some code here }

More about the XMLHttpRequest Object (continue…) 2. The readyState Property The readyState property holds the status of the server's response. Each time the readyState changes, the onreadystatechange function will be executed. Here are the possible values for the readyState property: State Description 0 The request is not initialized 1 The request has been set up 2 The request has been sent 3 The request is in process 4 The request is complete

More about the XMLHttpRequest Object (continue…) We are going to add an If statement to the onreadystatechange function to test if our response is complete (this means that we can get our data): xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { // Get the data from the server's response } } 3. The responseText Property The data sent back from the server can be retrieved with the responseText property. xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { document.getElementById("txt2").innerHTML=xmlHttp.responseText;

Sending a Request to the Server To send off a request to the server, we use the open() method and the send() method. The open() method takes three arguments. The first argument defines which method to use when sending the request (GET or POST). The second argument specifies the URL of the server-side script. The third argument specifies that the request should be handled asynchronously. The send() method sends the request off to the server. If we assume that the HTML and PHP file are in the same directory, the code would be: xmlHttp.open("GET",“ajax_sample.php",true); xmlHttp.send(null);

CGI Review http://fog.ccsf.edu/~hyip/cnit133/10/in_class_samples/cgireview.html http://fog.ccsf.edu/~hyip/cnit133/10/in_class_samples/cgireview_php. txt http://fog.ccsf.edu/~hyip/cnit133/10/in_class_samples/cgireview_2_p hp.html

Ajax – Get method, return string http://fog.ccsf.edu/~hyip/cnit133/10/in_class_samples/ajax_sample.ht ml http://fog.ccsf.edu/~hyip/cnit133/10/in_class_samples/ajax_sample_p hp.txt

Ajax – Post method, No Data sent to PHP, return string http://fog.ccsf.edu/~hyip/cnit133/10/in_class_samples/ajax_sample_2. html http://fog.ccsf.edu/~hyip/cnit133/10/in_class_samples/ajax_sample_2 _php.txt

Ajax – Post method, Data sent to PHP, return string http://fog.ccsf.edu/~hyip/cnit133/10/in_class_samples/ajax_sample_3. html http://fog.ccsf.edu/~hyip/cnit133/10/in_class_samples/ajax_sample_3 _php.txt

Ajax – Get method, No data sent to PHP, return XML data http://fog.ccsf.edu/~hyip/cnit133/10/samples/note.html http://fog.ccsf.edu/~hyip/cnit133/10/samples/ajax_sample_js.txt http://fog.ccsf.edu/~hyip/cnit133/10/samples/note_php.txt