Table of Contents. 1. A Quick Overview of Web Development...1 EVALUATION COPY

Size: px
Start display at page:

Download "Table of Contents. 1. A Quick Overview of Web Development...1 EVALUATION COPY"

Transcription

1 Table of Contents Table of Contents 1. A Quick Overview of Web Development...1 Client-side Programming...1 HTML...1 Cascading Style Sheets...1 JavaScript...1 Dynamic HTML...1 Ajax...1 Adobe Flash...2 Server-side Programming...2 Perl...2 ColdFusion...2 Active Server Pages...3 Java EE...3 ASP.NET...3 PHP...4 Ruby on Rails Intro to Ajax and the Node.js Server...5 The Purpose of Ajax...5 Traditional Web Application...5 JavaScript on the Server Side?...8 Why Node.js?...9 Installing Node.js...9 Running Node.js...9 A First Node.js Application & Server...10 An Ajax Web Application...13 Exercise 1: Adding a New Route to a Node.js Application Ajax Basics...23 The XMLHttpRequest Object...23 Using an XMLHttpRequest Object...24 Handling the Response...27 Exercise 2: Ajax using the POST method...32 The Callback Function...36 Exercise 3: Displaying and Updating Records...39 Version: Printed: i

2 Table of Contents 4. jquery...49 jquery: A JavaScript Library...49 About jquery...49 jquery Basics...49 Ajax with jquery...52 jquery's Ajax-Related Methods...54 Convenience Methods...61 $.fn.load...62 Exercise 4: Displaying Customer List in a Table with jquery Passing Data...71 XML...71 Creating an addchild() Function...77 Exercise 5: Using addchild()...80 Dynamic Tables...85 Exercise 6: Handling responsexml...92 JSON...99 Review of Object Literals...99 Arrays...99 Objects...99 Arrays in Objects...99 Objects in Arrays Back to JSON JSON Syntax JSON Parsers Exercise 7: Using JSON JSON Advantages and Disadvantages Ajax Applications Login Form Quick Lookup Form Exercise 8: Creating a Simple Lookup Form Preloaded Data Ajax Slideshow Navigable Tables Exercise 9: Create Navigable Table Rows More Ajax Applications Inline Editing The contenteditable Attribute Exercise 10: Using contenteditable for Inline Editing Detailed Information on Demand Autologout Autocompletion ii Copyright 2014 Webucator. All rights reserved.

3 Table of Contents 8. CORS/JSONP CORS/JSONP: Accessing Remote Sites CORS Exercise 11: Retrieving Country Info from GeoNames via CORS JSONP Exercise 12: Retrieving State Names from Yahoo! with JSONP CORS Vs. JSONP Differences Version: Printed: iii

4

5 A Quick Overview of Web Development 1. A Quick Overview of Web Development 1.1 In this lesson, you will learn About client-side web development languages. 2. About server-side web development languages. Web development involves a combination of client-side programming and server-side programming. Client-side Programming Client-side programming involves writing code that is interpreted by a browser such as Internet Explorer or Mozilla Firefox or by any other web client such as a cell phone. The most common languages and technologies used in client-side programming are HTML, JavaScript, Cascading Style Sheets (CSS), and Adobe Flash. HTML HyperText Markup Language (HTML) is the language behind most web pages. The language is made up of elements that describe the structure and format of the content on a web page. Cascading Style Sheets Cascading Style Sheets (CSS) is used in HTML pages to separate formatting and layout from content. Rules defining color, size, positioning and other display aspects of elements are defined in the HTML page or in linked CSS pages. JavaScript 1 JavaScript is used to make HTML pages more dynamic and interactive. It can be used to validate forms, pop up new windows, and create dynamic effects such as dropdown menus and image rollovers. Dynamic HTML Dynamic HTML is not a language in and of itself, but rather refers to code that uses JavaScript to manipulate CSS properties on the fly. 1. The word "JavaScript" is a proprietary name for Netscape's version of ECMAScript. Microsoft's version of this language is called JScript. Version: Printed: Page 1 of 200

6 A Quick Overview of Web Development Ajax The term Ajax was originally a pseudo-acronym for "Asynchronous JavaScript And XML," 2 but is now used much more broadly to cover all methods of communicating with a server using JavaScript. The main purpose of Ajax is to provide a simple and standard means for a web page to communicate with the server without a complete page refresh. Adobe Flash At the time of this writing, according to Adobe's website, more than 97% of computers connected to the internet have Flash Player installed. The Flash Player is a plug-in to Internet Explorer and other web browsers. It enables browsers to display dynamic graphical web pages that can be visually more fluid than pages that are built with Dynamic HTML. Flash pages are called movies and they are created using special software (also called Flash). ActionScript, a language similar to JavaScript, is used to manipulate Flash objects to make movies more interactive. At the time of this writing, designers are either moving to JavaScript or converting existing Flash videos to HTML5. However, converting is a challenge because not all features of Flash can be converted. Tools to solve this issue are currently being introduced by Adobe (with Wallaby) and Google (with Swiffy) and others. 1.2 Server-side Programming Server-side programming involves writing code that connects web pages with databases, XML pages, servers, file systems and other systems and software accessible from the web server. The most common server-side languages and programming frameworks are Perl, ColdFusion, Active Server Pages, Java (in many flavors), ASP.NET and PHP. Perl Perl was the first server-side language to become popular in web development. Originally derived from C, its relative simplicity and strengths in file and text manipulation and the fact that it is open source made it a good choice for writing CGI scripts. Although Perl is still widely used, it is not as popular a choice for new web projects as some of the other server-side languages discussed below. 2. Ajax: A New Approach to Web Applications - Page 2 of 200 Copyright 2014 Webucator. All rights reserved.

7 ColdFusion ColdFusion, created by Allaire (now owned by Adobe), is arguably the simplest of all server-side languages. It is tag-based, which makes it look a lot like HTML and easier for client-side programmers to understand than some of the other choices. Because of the relative ease with which it is written, ColdFusion is sometimes assumed not to be so powerful. In fact, ColdFusion code is compiled to Java bytecode, which means the pages run quickly. Web developers can accomplish virtually any required task using the ColdFusion Markup Language (CFML). However, as ColdFusion can easily be integrated with Java applications, developers have the choice of using Java to extend ColdFusion applications. Active Server Pages Microsoft Active Server Pages (ASP) is a framework that allows developers to write server-side pages in many scripting languages; however, VBScript and JScript are the only commonly used choices. ASP became popular quickly and sites with pages ending in.asp are now all over the web. It is not as simple as ColdFusion, but it has the huge advantage of being built in to Microsoft Internet Information Server (IIS). Although still commonly used, ASP has been replaced by Microsoft with ASP.NET, an architecture that is much more similar to Java's than to traditional ASP's. Java EE Java EE is used in large web projects. With its power and robustness comes a steep learning curve. Java EE is defined by its specification ( cle.com/javaee/) and API ( A Java Application Server (Java AS) manages servlets, JavaServer Pages (JSP), Web Services, and Enterprise JavaBeans (EJB). Java EE also includes a number of other APIs commonly linked to enterprise application development. JDBC, JPA, , JMS, and XML are some examples. But that's only part of the picture. There are a number of frameworks built on some of these technologies that streamlines the development process further. Hibernate offers most of the object/relational mapping (ORM) without an EJB Container. For this reason it's called a lightweight ORM technology. JavaServer Faces, Struts, and Spring-MVC build on JSP to do away with scriptlets completely, relying on HTML style tags and associated JavaBeans. ASP.NET A Quick Overview of Web Development Microsoft's ASP.NET is not a language, but a framework for writing websites and software. Like ColdFusion and JSP (and unlike traditional ASP) ASP.NET pages are precompiled, so they run faster than traditional ASP pages do. ASP.NET pages Version: Printed: Page 3 of 200

8 A Quick Overview of Web Development can be written in many languages, but the most popular are C# (pronounced C-sharp) and Visual Basic.NET (VB.NET). PHP Like Perl, PHP is open source. It has rapidly become a popular alternative to the proprietary languages such as ColdFusion and ASP.NET. PHP is lightweight, relatively simple to learn and runs on almost all commonly used web servers. A nice feature is that it can be integrated with both Java and COM. Ruby on Rails Wikipedia describes Ruby on Rails as "a web application framework that aims to increase the speed and ease with which database-driven websites can be created and offers skeleton code frameworks (scaffolding) from the outset. Often shortened to Rails, or RoR, Ruby On Rails is an open source project written in the Ruby programming language and applications using the Rails framework are developed using the Model-View-Controller design pattern." Conclusion This lesson has provided a general overview of the different languages and frameworks commonly used in web development Page 4 of 200 Copyright 2014 Webucator. All rights reserved.

9 3. Ajax Basics In this lesson, you will learn How Ajax Works. 2. How to create cross-browser Ajax. 3. How to send data using Head, Get and Post methods. As a way of review, the term AJAX is a pseudo-acronym for "Asynchronous JavaScript And XML," 5 but is now used much more broadly to cover all methods of communicating with a server using JavaScript. Again, Ajax 6 is not always asynchronous and does not always involve XML. 3.1 The XMLHttpRequest Object Later in this course we will look at how using JavaScript libraries like jquery can make working with Ajax quicker and easier. To start, though, it makes sense to review the underlying code to see how the actual Ajax calls and response-handling work. Your work here will make using jquery (or other libraries) easier - and you'll understand what the jquery convenience functions are actually doing. The mechanism for sending data to and retrieving data from the server with Ajax is the XMLHttpRequest object. Until HTML5, the XMLHttpRequest Object wasn't officially part of any common specification; however, all the major browsers have supported it for some time. Later in the course we will use jquery, a JavaScript library, to create Ajax functionality. The HTML5 method is straightforward. It uses a simple XMLHttpRequest() constructor to create the object. 5. Ajax: A New Approach to Web Applications Although it is not uncommon to see the term written in all capital letters (AJAX), it has become standard to write it as Ajax. Version: Printed: Page 23 of 200

10 Code Sample AjaxBasics/Demos/CreateXMLHttpRequest.html <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <script type="text/javascript" src="lib.js"></script> <script type="text/javascript"> function start() { if (window.xmlhttprequest) { var xmlhttp = new XMLHttpRequest(); document.getelementbyid("content").innerhtml = "<h1>using XMLHttpRequest Object</h1>"; else { var xmlhttp = false; document.getelementbyid("content").innerhtml = "<h1>xmlhttp cannot be created!</h1>"; observeevent(window, "load", function() { var btn = document.getelementbyid("btnstart"); observeevent(btn, "click", start); ); </script> <title>xmlhttprequest - HTML5 Method</title> </head> <body> <button id="btnstart">start</button> <div id="content"></div> </body> </html> Code Explanation This code attempts to create an XMLHttpRequest object using the XMLHttpRequest() constructor. If it succeeds, it writes out "Using XMLHttpRequest Object" to the body of the page. If it fails, it writes out "XMLHttp cannot be created!" Page 24 of 200 Copyright 2014 Webucator. All rights reserved.

11 Using an XMLHttpRequest Object So, now that we have an XMLHttpRequest object created, what do we do with it? We use it to make HTTP requests. To do so, we initialize the object with the open() method, which takes three arguments. XMLHttpRequest open() Method Arguments Argument Description Request Type URL String. Usually POST, GET, or HEAD String. The URL receiving the request. Asynchronous Boolean. Whether the request should be made asynchronously (true) or synchronously (false). A typical open() method call is shown below. xmlhttp.open("get","demo.xml",true); Ajax Basics Request Types Although the HTTP specification identifies several methods of HTTP requests 7, the most commonly supported (and used) methods are GET, POST and HEAD. HEAD The HEAD method is the least commonly used of the three; however, for simple requests, it can be all you need. It simply returns the meta-information contained in the HTTP headers. The call would look like this: xmlhttp.open("head","demo",true); And the response might look like this: Date: Wed, 11 May :46:30 GMT X-Powered-By: ASP.NET Content-Length: 63 Last-Modified: Tue, 10 May :12:27 GMT Server: Microsoft-IIS/7.5 ETag: "712b13346fcc1:0" Content-Type: text/xml Accept-Ranges: bytes The XMLHttpRequest request is sent as follows: 7. Version: Printed: Page 25 of 200

12 xmlhttp.send(null); We'll explain why null is passed in just a moment. GET The GET method is used to send information to the server as part of the URL. The server returns the same header information that the HEAD method returns, but it also returns the body of the message (i.e, the content of the page). Any name-value pairs to be processed by the receiving page should be passed along the querystring. The call would look like this: xmlhttp.open("get","demo?firstname=nat&lastname=dunn",true); The response would be the same as the response shown for the HEAD method followed by the message body, which would typically be simple text, JSON, HTML or XML. Again, the XMLHttpRequest request is sent as follows: xmlhttp.send(null); POST The POST method is used to send information as an enclosed entity. The call would look like this: xmlhttp.open("post","demo",true); The response header is somewhat different in that it specifies that the returned content is not cacheable. Like with GET, the message body would typically be plain text, HTML or XML. The XMLHttpRequest request is sent as follows: xmlhttp.setrequestheader("content-type","application/x-www-form-ur»» lencoded;charset=utf-8"); xmlhttp.send("firstname=nat&lastname=dunn"); As you can see, with POST, we first need to set the content type to "application/x-www-form-urlencoded;charset=utf-8". This tells the server to expect Page 26 of 200 Copyright 2014 Webucator. All rights reserved.

13 form data. In the send method, we include name-value pairs. These name-value pairs are available to the receiving page for processing. Data can be sent in this manner with the HEAD and GET methods, which is why null was passed in the previous examples. Asynchronous vs. Synchronous Requests The asynchronous argument should almost always be set to true. After all, that's the "A" in Ajax. Synchronous calls force the browser to wait for a response from the server before continuing. This leaves the user unable to interact with the browser until the response is complete. Asynchronous requests allow the browser to continue to process code while waiting for a response. Handling the Response When using asynchronous calls, we cannot be sure when the response will come, so we must write code that waits for the response and handles it when it arrives. We do this with a callback function. Callback functions are functions that are triggered by some event. In our case, the event we are looking for is a change in the state of the xmlhttp response. The xmlhttp object's readystate property holds the current state of the response. There are five possible states (0-4), which are described below. Browsers do not necessarily inform you of all states; states 0 and 3 in particular may not appear when you run the demo file. Values of the readystate Property State Description uninitialized loading loaded interactive complete Each change in the readystate is captured by the xmlhttp object's onreadystatechange event handler. We can assign a callback function to this property like this: Version: Printed: Page 27 of 200

14 Code Sample xmlhttp.onreadystatechange = function() { //Do something here This use of an anonymous or unnamed function may be new to you. In JavaScript, functions are first-class objects and can be assigned to variables or properties of other objects. We could also create a named function and assign that function to xmlhttp.onreadystatechange like this: xmlhttp.onreadystatechange = handler; The following sample file illustrates how the readystatechange event is handled. AjaxBasics/Demos/ReadyStateChange.html Lines 1 through 7 Omitted <script type="text/javascript"> function start() { var xmlhttp = new XMLHttpRequest(); var contentdiv = document.getelementbyid("content"); xmlhttp.open("head", "Demo.xml", true); xmlhttp.onreadystatechange = function() { contentdiv.innerhtml += "Ready State: " + xmlhttp.readystate + "<br>"; xmlhttp.send(null); Lines 20 through 31 Omitted Page 28 of 200 Copyright 2014 Webucator. All rights reserved.

15 Code Explanation The output will look something like this. The actual ready states returned will depend on your setup. In practice, before doing anything with the xmlhttp response data, we want to make sure the readystate is complete (4), so we put a condition inside our function to check for this: xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4) { //Do something here Now we're ready to do something with the data returned. Before looking at an example, let's take a look at the properties and methods of the xmlhttp object, so we know what's available to us. Version: Printed: Page 29 of 200

16 XMLHttpRequest Object Properties Property onreadystatechange readystate responsetext responsexml status statustext Description Specifies the callback function to be triggered when the ready state changes. Holds the state of the response. Holds the message body as a string. Holds the message body as an XML object. Holds the status code returned from the server (e.g, 200 for success, 404 for page not found, etc.). Holds the status text returned from the server. XMLHttpRequest Object Methods Method abort() getallresponseheaders() getresponseheader(header) open(method,url,async) send(postdata) setrequestheader(header,value) Description Aborts the xmlhttp request. Retrieves the values of all the HTTP headers as a string. Retrieves the value of the specified HTTP header as a string. Initializes the XMLHttpRequest object. Sends the HTTP request to the server. Specifies the name and value of an HTTP header. A common application is to check the status property to make sure that the request was successful (200) and then to output the message body to a div on the HTML page. The following sample file demonstrates this. To run the demo, first start the Node.js server: 1. Open the command line (on a PC) or terminal (on a Mac), and navigate to the directory AjaxBasics/Demos/. 2. Type npm install. 3. Type npm start to start the Node.js server. With the server started, you can then browse to HttpRequest-Get.html to view the page. Page 30 of 200 Copyright 2014 Webucator. All rights reserved.

17 Code Sample AjaxBasics/Demos/UsingXMLHttpRequest-Get.html Lines 1 through 8 Omitted function start() { var xmlhttp = new XMLHttpRequest(); var contentdiv = document.getelementbyid("content"); xmlhttp.open("get", "Demo?FirstName=Nat&LastName=Dunn", true); xmlhttp.onreadystatechange = function() { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { contentdiv.innerhtml = xmlhttp.responsetext; xmlhttp.send(null); Lines 21 through 32 Omitted Code Explanation This page simply "copies" the response text (xmlhttp.responsetext) and "pastes" it into the "Content" div on the page. Version: Printed: Page 31 of 200

18 Exercise 2 10 to 15 minutes Exercise Code Ajax using the POST method In this exercise, you will modify the code from the last demonstration to send data using the POST method. You will need to use the setrequestheader() method to alert the server to expect form data. 1. If needed, stop (by pressing ctrl-c from the command line) any running instance of the Node.js. 2. Navigate to the directory AjaxBasics/Exercises/ in command line. 3. Type npm install from the command line, to install the needed Node.js modules. 4. Type npm start to start the Node.js server. 5. Open AjaxBasics/Exercises/UsingXMLHttpRequest-Post.html in your editor. 6. Modify the code to make the request using the POST method shown earlier (see page 26). 7. Test your solution in a browser by visiting AjaxBasics/Exercises/UsingXMLHttpRequest-Post.html Lines 1 through 6 Omitted <script type="text/javascript"> function start() { var xmlhttp = new XMLHttpRequest(); var contentdiv = document.getelementbyid("content"); xmlhttp.open("get", "Demo?FirstName=Nat&LastName=Dunn", true); xmlhttp.onreadystatechange = function() { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { contentdiv.innerhtml = xmlhttp.responsetext; xmlhttp.send(null); observeevent(window, "load", function() { var btn = document.getelementbyid("btnstart"); observeevent(btn, "click", start); ); </script> Lines 26 through 31 Omitted Page 32 of 200 Copyright 2014 Webucator. All rights reserved.

19 *Challenge Write out all the response headers to the end of the same "Content" div. Version: Printed: Page 33 of 200

20 Exercise Solution AjaxBasics/Solutions/UsingXMLHttpRequest-Post.html Lines 1 through 7 Omitted function start() { var xmlhttp = new XMLHttpRequest(); var contentdiv = document.getelementbyid("content"); xmlhttp.open("post", "Demo", true); xmlhttp.onreadystatechange = function() { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { contentdiv.innerhtml = xmlhttp.responsetext; xmlhttp.setrequestheader("content-type", "application/x-www-form-ur»» lencoded;charset=utf-8"); xmlhttp.send("firstname=nat&lastname=dunn"); Lines 21 through 32 Omitted Code Explanation We specify "POST" as the method for our Ajax call in xmlhttp.open and, in xmlhttp.setrequestheader specify the MIME type (application/x-www-form-urlencoded) and character encoding (charset=utf-8) of the request we send to the /Demo response route. We pass along two POST variables, FirstName and LastName, with values Nat and Dunn, respectively. Page 34 of 200 Copyright 2014 Webucator. All rights reserved.

21 Challenge Solution AjaxBasics/Solutions/UsingXMLHttpRequest-Post-Challenge.html Lines 1 through 7 Omitted function start() { var xmlhttp = new XMLHttpRequest(); var contentdiv = document.getelementbyid("content"); xmlhttp.open("post", "Demo", true); xmlhttp.onreadystatechange = function() { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { contentdiv.innerhtml = xmlhttp.responsetext; var headers = xmlhttp.getallresponseheaders(); contentdiv.innerhtml += headers.replace(/\n/g, "<br>"); xmlhttp.setrequestheader("content-type", "application/x-www-form-ur»» lencoded;charset=utf-8"); xmlhttp.send("firstname=nat&lastname=dunn"); Lines 23 through 34 Omitted Code Explanation We use innerhtml to set the contents of #contentdiv, retrieving the response headers with xmlhttp.getallresponseheaders() and displaying with newlines converted to HTML <br /> tags. Version: Printed: Page 35 of 200

22 3.2 The Callback Function In the demos thus far, we have used anonymous callback functions to hanndle the Ajax response, like so: Anonymous Callback Function xmlhttp.onreadystatechange=function() { //handle response As these anonymous functions are nested within the original function, they have access to the variable set in the original function. That's why we can reuse the xmlhttp and contentdiv variables within the callback function: Callback as Anonymous Function function start() { var xmlhttp = new XMLHttpRequest(); var contentdiv = document.getelementbyid("content"); xmlhttp.open("post", "Demo", true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { contentdiv.innerhtml=xmlhttp.responsetext; xmlhttp.setrequestheader("content-type","application/x-www-formurlencoded;charset=utf-8"); xmlhttp.send("firstname=nat&lastname=dunn"); But callback functions don't have to be anonymous or nested. Another way to write this is shown below: Page 36 of 200 Copyright 2014 Webucator. All rights reserved.

23 Callback as Top-Level Function: Global Variables var xmlhttp = new XMLHttpRequest(); var contentdiv = document.getelementbyid("content"); function mycallback() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { contentdiv.innerhtml=xmlhttp.responsetext; The problem with this method is that it uses global variables. This can be problematic as the variables can easily be unintentionally and unexpectedly overwritten. One way around this is to use an anonymous callback function to make the call to the now-pseudo-callback function and pass the necessary variables into it, like this: Callback as Top-Level Function: Passing Variables function start() { xmlhttp.open("post", "Demo", true); xmlhttp.onreadystatechange=mycallback; xmlhttp.setrequestheader("content-type","application/x-www-formurlencoded;charset=utf-8"); xmlhttp.send("firstname=nat&lastname=dunn"); function start() { var xmlhttp = new XMLHttpRequest(); var contentdiv = document.getelementbyid("content"); xmlhttp.open("post", "Demo", true); xmlhttp.onreadystatechange=function() { mycallback(xmlhttp, contentdiv); ; xmlhttp.setrequestheader("content-type","application/x-www-formurlencoded;charset=utf-8"); xmlhttp.send("firstname=nat&lastname=dunn"); function mycallback(xmlhttp, contentdiv) { if (xmlhttp.readystate==4 && xmlhttp.status==200) { contentdiv.innerhtml=xmlhttp.responsetext; Another way to handle it is to nest a named callback function within the original function. As JavaScript functions are objects, they can have their own methods, so you can do the following: Version: Printed: Page 37 of 200

24 Callback as Nested Named Function function start() { var xmlhttp = new XMLHttpRequest(); var contentdiv = document.getelementbyid("content"); xmlhttp.open("post", "Demo", true); xmlhttp.onreadystatechange=mycallback; xmlhttp.setrequestheader("content-type","application/x-www-formurlencoded;charset=utf-8"); xmlhttp.send("firstname=nat&lastname=dunn"); function mycallback() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { contentdiv.innerhtml=xmlhttp.responsetext; Because the callback function is nested within the start() function, it has access to the xmlhttp and contentdiv variables. The only limitation of this method is that the mycallback() function is not callable from outside the start() function. Depending on what you're trying to do, that may or may not be an issue. Page 38 of 200 Copyright 2014 Webucator. All rights reserved.

25 Exercise 3 30 to 40 minutes Displaying and Updating Records In this exercise, you will create a mini-application for displaying and updating employee records. The server-side files are already created and much of the JavaScript is written for you. You will have to finish the Ajax portions of the code. 1. From the command line, navigate to the directory AjaxBasics/Exercises/. 2. Type npm start to start the Node.js server. 3. Note that the code already created for you makes an Ajax call to /EmployeeList. Generated by Node.js, this call returns a list of the employees, as shown below: <ul> <li id="emp1">nancy Davolio</li> <li id="emp2">andrew Fuller</li> <li id="emp3">janet Leverling</li> <li id="emp4">margaret Peacock</li> <li id="emp5">steven Buchanan</li> <li id="emp6">michael Suyama</li> <li id="emp7">robert King</li> <li id="emp8">laura Callahan</li> <li id="emp9">anne Dodsworth</li> </ul> Ajax Basics Notice the ids of the list items are the employee id from the database prefixed with "emp". Version: Printed: Page 39 of 200

26 4. Open AjaxBasics/Exercises/EmployeeAdmin.html for editing. This is where you'll do your work. A. In the getemployeelist() function where the comment is: open an asynchronous XMLHttpRequest using the GET method and the URL passed into the function. When the readystate of the request changes, call the display() function with the appropriate parameters. Send the request. B. In the display() function: Set the innerhtml property of output div to the responsetext of the returned xmlhttp object. Test your solution to this piece by opening AjaxBasics/Exercises/EmployeeAdmin.html in your browser. You should see a list of the employees. If you do not, check your getemployeelist() and display() functions. C. Finish the getemployeeform() function by setting the appropriate content type for submitting form data and sending the request. D. In the updateemployee() function: Write the code leading up to the call to send() method call. When the readystate of the request changes, call the employeeupdated() function. 5. Test your solution in a browser by visiting min.html *Challenge In the employeeupdated() callback function, we currently call getemployeelist() to update the list of employees. This updates the entire list after each change. It would be better to just update the record that was changed. There is no need to make a call to the database to find out which record it was or how it was changed. The client already has that information. See if you can figure out how to remove this unnecessary Ajax call and use pure client-side JavaScript to update the list. Be careful not to update the list until you are sure that the record has been successfully updated in the database. The only file you will need to change is EmployeeAdmin.html. Page 40 of 200 Copyright 2014 Webucator. All rights reserved.

27 Version: Printed: Page 41 of 200

28 Exercise Solution AjaxBasics/Solutions/EmployeeAdmin.html Lines 1 through 8 Omitted function getemployeelist(url) { var xmlhttp = new XMLHttpRequest(); var output = document.getelementbyid("employeelist"); output.innerhtml = "<h2>loading...</h2>"; xmlhttp.open("get", url, true); xmlhttp.onreadystatechange = function() { display(output, xmlhttp); xmlhttp.send(null); function display(output, xmlhttp) { var employees, eid, target, i; if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { output.style.display = "block"; output.innerhtml = xmlhttp.responsetext; if (xmlhttp.responsetext.indexof("failed") == 0) { output.classname = "Warning"; else { employees = output.getelementsbytagname("li"); for (i = 0; i < employees.length; ++i) { observeevent(employees[i], "click", function(e) { target = gettarget(e); eid = target.id.substring(3); getemployeeform("employeeform", eid); ); function getemployeeform(url, eid) { var xmlhttp = new XMLHttpRequest(); var output = document.getelementbyid("formdiv"); var fields, field, value, i; output.innerhtml = "Loading..."; xmlhttp.open("post", url, true); Page 42 of 200 Copyright 2014 Webucator. All rights reserved.

29 xmlhttp.onreadystatechange = function() { display(output, xmlhttp); fields = output.getelementsbytagname("input"); for (i = 0; i < fields.length; ++i) { observeevent(fields[i], "change", function(e) { target = gettarget(e); field = target.name; value = target.value; updateemployee("editemployee", field, value, eid); ); xmlhttp.setrequestheader("content-type", "application/x-www-form-ur»» lencoded;charset=utf-8"); xmlhttp.send("eid=" + eid); function updateemployee(url, field, value, eid) { var xmlhttp = new XMLHttpRequest(); xmlhttp.open("post", url, true); xmlhttp.onreadystatechange = employeeupdated; xmlhttp.setrequestheader("content-type", "application/x-www-form-ur»» lencoded;charset=utf-8"); xmlhttp.send("eid=" + eid + "&field=" + field + "&value=" + value); function employeeupdated() { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { var msg = document.getelementbyid("messagediv"); if (xmlhttp.responsetext.indexof("failed") == 0) { msg.classname = "Warning"; msg.innerhtml = xmlhttp.responsetext; else { msg.innerhtml = "Updated!"; getemployeelist('employeelist'); fadeelem(msg, 255, 255, 0, 255, 255, 255); Lines 84 through 97 Omitted Version: Printed: Page 43 of 200

30 Code Explanation Open in your browser to view the solution; be sure to start the Node.js server (by typing npm start from the command line) in the AjaxBasics/Solutions/ directory first. Function getemployeelist, invoked when the page loads, makes an Ajax call to /EmployeeList and invokes function display. If the Ajax calls is successful, then function display displays the returned list of employees in div#employeelist. Also in function display we iterate over each of the bulleted names, listening for clicks. A click on any of the names results in a call to function getemployeeform, passing along the id of the clicked-upon employee. Function getemployeeform, in turn, makes an Ajax request, via the POST method, to /EmployeeForm, displays the returned form, and adds change handlers on each of the fields of the form. As a result of the handlers added in function getemployeeform, a change to any of the employee-form fields invokes function updateemployee which, in turn, makes a POST Ajax request to /EditEmployee, sending along the id of the employee, field name, and field value. The function displays a success or failure message based on the status of the returned results. Page 44 of 200 Copyright 2014 Webucator. All rights reserved.

31 Challenge Solution AjaxBasics/Solutions/EmployeeAdmin-challenge.html Lines 1 through 39 Omitted function getemployeeform(url, eid) { var xmlhttp = new XMLHttpRequest(); var output = document.getelementbyid("formdiv"); var fields, field, value, i, fname, lname; output.innerhtml = "Loading..."; xmlhttp.open("post", url, true); xmlhttp.onreadystatechange = function() { display(output, xmlhttp); fields = output.getelementsbytagname("input"); for (i = 0; i < fields.length; ++i) { observeevent(fields[i], "change", function(e) { target = gettarget(e); field = target.name; value = target.value; fname = target.form.firstname.value; lname = target.form.lastname.value; updateemployee("editemployee", field, value, eid, fname, lname); ); xmlhttp.setrequestheader("content-type", "application/x-www-form-ur»» lencoded;charset=utf-8"); xmlhttp.send("eid=" + eid); function updateemployee(url, field, value, eid, fname, lname) { var xmlhttp = new XMLHttpRequest(); xmlhttp.open("post", url, true); xmlhttp.onreadystatechange = function() { employeeupdated(eid, fname, lname); ; xmlhttp.setrequestheader("content-type", "application/x-www-form-ur»» lencoded;charset=utf-8"); xmlhttp.send("eid=" + eid + "&field=" + field + "&value=" + value); function employeeupdated(eid, fname, lname) { var employee, msg; Version: Printed: Page 45 of 200

32 if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { msg = document.getelementbyid("messagediv"); if (xmlhttp.responsetext.indexof("failed") == 0) { msg.classname = "Warning"; msg.innerhtml = xmlhttp.responsetext; else { msg.innerhtml = "Updated!"; employee = document.getelementbyid("emp" + eid); employee.innerhtml = fname + ' ' + lname; fadeelem(msg, 255, 255, 0, 255, 255, 255); Lines 90 through 104 Omitted Code Explanation Open in your browser to view the solution. In function getemployeeform, we now keep track of the first and last name (from the fields with ids FirstName and LastName, respectively) of each employee. We pass these values as parameters in the call to updateemployee when any of the fields is changed. Function updateemployee works largely as before but, upon successful update of the employee (i.e. a successful Ajax response code), the function now sets the displayed name of the relevant employee in the bulleted list. Page 46 of 200 Copyright 2014 Webucator. All rights reserved.

33 3.3 Conclusion In this lesson, you have learned the basic foundation for creating Ajax applications. Version: Printed: Page 47 of 200

34 Page 48 of 200 Copyright 2014 Webucator. All rights reserved.

is Introduction to HTML

is Introduction to HTML or tri N s di IO n tio AT uc od pr re U ed AL riz ho ut na EV U n is i ib d tie PY oh pr O C io t bu Introduction to HTML (HTM101 version 4.1.0) Copyright Information Copyright 2017 Webucator. All rights

More information

Introduction to HTML EVALUATION COPY. (HTM101 version 3.1.5) Copyright Information. Copyright 2013 Webucator. All rights reserved.

Introduction to HTML EVALUATION COPY. (HTM101 version 3.1.5) Copyright Information. Copyright 2013 Webucator. All rights reserved. Introduction to HTML (HTM101 version 3.1.5) Copyright Information Copyright 2013 Webucator. All rights reserved. The Author Nat Dunn Nat Dunn founded Webucator in 2003 to combine his passion for web development

More information

AJAX. Introduction. AJAX: Asynchronous JavaScript and XML

AJAX. Introduction. AJAX: Asynchronous JavaScript and XML AJAX 1 2 Introduction AJAX: Asynchronous JavaScript and XML Popular in 2005 by Google Create interactive web applications Exchange small amounts of data with the server behind the scenes No need to reload

More information

XMLHttpRequest. CS144: Web Applications

XMLHttpRequest. CS144: Web Applications XMLHttpRequest http://oak.cs.ucla.edu/cs144/examples/google-suggest.html Q: What is going on behind the scene? What events does it monitor? What does it do when

More information

AJAX(Asynchronous Javascript + XML) Creating client-side dynamic Web pages

AJAX(Asynchronous Javascript + XML) Creating client-side dynamic Web pages AJAX(Asynchronous Javascript + XML) Creating client-side dynamic Web pages AJAX = Asynchronous JavaScript and XML.AJAX is not a new programming language, but a new way to use existing standards. AJAX is

More information

Ajax Ajax Ajax = Asynchronous JavaScript and XML Using a set of methods built in to JavaScript to transfer data between the browser and a server in the background Reduces the amount of data that must be

More information

AJAX. Lecture 26. Robb T. Koether. Fri, Mar 21, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) AJAX Fri, Mar 21, / 16

AJAX. Lecture 26. Robb T. Koether. Fri, Mar 21, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) AJAX Fri, Mar 21, / 16 AJAX Lecture 26 Robb T. Koether Hampden-Sydney College Fri, Mar 21, 2014 Robb T. Koether (Hampden-Sydney College) AJAX Fri, Mar 21, 2014 1 / 16 1 AJAX 2 Http Requests 3 Request States 4 Handling the Response

More information

A.A. 2008/09. What is Ajax?

A.A. 2008/09. What is Ajax? Internet t Software Technologies AJAX IMCNE A.A. 2008/09 Gabriele Cecchetti What is Ajax? AJAX stands for Asynchronous JavaScript And XML. AJAX is a type of programming made popular in 2005 by Google (with

More information

AJAX: Introduction CISC 282 November 27, 2018

AJAX: Introduction CISC 282 November 27, 2018 AJAX: Introduction CISC 282 November 27, 2018 Synchronous Communication User and server take turns waiting User requests pages while browsing Waits for server to respond Waits for the page to load in the

More information

Ajax Ajax Ajax = Asynchronous JavaScript and XML Using a set of methods built in to JavaScript to transfer data between the browser and a server in the background Reduces the amount of data that must be

More information

Use of PHP for DB Connection. Middle and Information Tier

Use of PHP for DB Connection. Middle and Information Tier Client: UI HTML, JavaScript, CSS, XML Use of PHP for DB Connection Middle Get all books with keyword web programming PHP Format the output, i.e., data returned from the DB SQL DB Query Access/MySQL 1 2

More information

E ECMAScript, 21 elements collection, HTML, 30 31, 31. Index 161

E ECMAScript, 21 elements collection, HTML, 30 31, 31. Index 161 A element, 108 accessing objects within HTML, using JavaScript, 27 28, 28 activatediv()/deactivatediv(), 114 115, 115 ActiveXObject, AJAX and, 132, 140 adding information to page dynamically, 30, 30,

More information

CITS1231 Web Technologies. Ajax and Web 2.0 Turning clunky website into interactive mashups

CITS1231 Web Technologies. Ajax and Web 2.0 Turning clunky website into interactive mashups CITS1231 Web Technologies Ajax and Web 2.0 Turning clunky website into interactive mashups What is Ajax? Shorthand for Asynchronous JavaScript and XML. Coined by Jesse James Garrett of Adaptive Path. Helps

More information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript CS 4640 Programming Languages for Web Applications JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation

More information

Module7: AJAX. Click, wait, and refresh user interaction. Synchronous request/response communication model. Page-driven: Workflow is based on pages

Module7: AJAX. Click, wait, and refresh user interaction. Synchronous request/response communication model. Page-driven: Workflow is based on pages INTERNET & WEB APPLICATION DEVELOPMENT SWE 444 Fall Semester 2008-2009 (081) Module7: Objectives/Outline Objectives Outline Understand the role of Learn how to use in your web applications Rich User Experience

More information

Term Paper. P r o f. D r. E d u a r d H e i n d l. H o c h s c h u l e F u r t w a n g e n U n i v e r s i t y. P r e s e n t e d T o :

Term Paper. P r o f. D r. E d u a r d H e i n d l. H o c h s c h u l e F u r t w a n g e n U n i v e r s i t y. P r e s e n t e d T o : Version: 0.1 Date: 02.05.2009 Author(s): Doddy Satyasree AJAX Person responsable: Doddy Satyasree Language: English Term Paper History Version Status Date 0.1 Draft Version created 02.05.2009 0.2 Final

More information

Fall Semester (081) Module7: AJAX

Fall Semester (081) Module7: AJAX INTERNET & WEB APPLICATION DEVELOPMENT SWE 444 Fall Semester 2008-2009 (081) Module7: AJAX Dr. El-Sayed El-Alfy Computer Science Department King Fahd University of Petroleum and Minerals alfy@kfupm.edu.sa

More information

Part of this connection identifies how the response can / should be provided to the client code via the use of a callback routine.

Part of this connection identifies how the response can / should be provided to the client code via the use of a callback routine. What is AJAX? In one sense, AJAX is simply an acronym for Asynchronous JavaScript And XML In another, it is a protocol for sending requests from a client (web page) to a server, and how the information

More information

AJAX: The Basics CISC 282 March 25, 2014

AJAX: The Basics CISC 282 March 25, 2014 AJAX: The Basics CISC 282 March 25, 2014 Synchronous Communication User and server take turns waiting User requests pages while browsing Waits for server to respond Waits for the page to load in the browser

More information

A synchronous J avascript A nd X ml

A synchronous J avascript A nd X ml A synchronous J avascript A nd X ml The problem AJAX solves: How to put data from the server onto a web page, without loading a new page or reloading the existing page. Ajax is the concept of combining

More information

AJAX ASYNCHRONOUS JAVASCRIPT AND XML. Laura Farinetti - DAUIN

AJAX ASYNCHRONOUS JAVASCRIPT AND XML. Laura Farinetti - DAUIN AJAX ASYNCHRONOUS JAVASCRIPT AND XML Laura Farinetti - DAUIN Rich-client asynchronous transactions In 2005, Jesse James Garrett wrote an online article titled Ajax: A New Approach to Web Applications (www.adaptivepath.com/ideas/essays/archives/000

More information

IT2353 WEB TECHNOLOGY Question Bank UNIT I 1. What is the difference between node and host? 2. What is the purpose of routers? 3. Define protocol. 4.

IT2353 WEB TECHNOLOGY Question Bank UNIT I 1. What is the difference between node and host? 2. What is the purpose of routers? 3. Define protocol. 4. IT2353 WEB TECHNOLOGY Question Bank UNIT I 1. What is the difference between node and host? 2. What is the purpose of routers? 3. Define protocol. 4. Why are the protocols layered? 5. Define encapsulation.

More information

The course also includes an overview of some of the most popular frameworks that you will most likely encounter in your real work environments.

The course also includes an overview of some of the most popular frameworks that you will most likely encounter in your real work environments. Web Development WEB101: Web Development Fundamentals using HTML, CSS and JavaScript $2,495.00 5 Days Replay Class Recordings included with this course Upcoming Dates Course Description This 5-day instructor-led

More information

1.1 A Brief Intro to the Internet

1.1 A Brief Intro to the Internet 1.1 A Brief Intro to the Internet - Origins - ARPAnet - late 1960s and early 1970s - Network reliability - For ARPA-funded research organizations - BITnet, CSnet - late 1970s & early 1980s - email and

More information

1.1 A Brief Intro to the Internet

1.1 A Brief Intro to the Internet 1.1 A Brief Intro to the Internet - Origins - ARPAnet - late 1960s and early 1970s - Network reliability - For ARPA-funded research organizations - BITnet, CSnet - late 1970s & early 1980s - email and

More information

AJAX: The Basics CISC 282 November 22, 2017

AJAX: The Basics CISC 282 November 22, 2017 AJAX: The Basics CISC 282 November 22, 2017 Synchronous Communication User and server take turns waiting User requests pages while browsing Waits for server to respond Waits for the page to load in the

More information

Session 11. Ajax. Reading & Reference

Session 11. Ajax. Reading & Reference Session 11 Ajax Reference XMLHttpRequest object Reading & Reference en.wikipedia.org/wiki/xmlhttprequest Specification developer.mozilla.org/en-us/docs/web/api/xmlhttprequest JavaScript (6th Edition) by

More information

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK Programming for Digital Media EE1707 JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK 1 References and Sources 1. Javascript & JQuery: interactive front-end

More information

Session 18. jquery - Ajax. Reference. Tutorials. jquery Methods. Session 18 jquery and Ajax 10/31/ Robert Kelly,

Session 18. jquery - Ajax. Reference. Tutorials. jquery Methods. Session 18 jquery and Ajax 10/31/ Robert Kelly, Session 18 jquery - Ajax 1 Tutorials Reference http://learn.jquery.com/ajax/ http://www.w3schools.com/jquery/jquery_ajax_intro.asp jquery Methods http://www.w3schools.com/jquery/jquery_ref_ajax.asp 2 10/31/2018

More information

WebApp development. Outline. Web app structure. HTML basics. 1. Fundamentals of a web app / website. Tiberiu Vilcu

WebApp development. Outline. Web app structure. HTML basics. 1. Fundamentals of a web app / website. Tiberiu Vilcu Outline WebApp development Tiberiu Vilcu Prepared for EECS 411 Sugih Jamin 20 September 2017 1 2 Web app structure HTML basics Back-end: Web server Database / data storage Front-end: HTML page CSS JavaScript

More information

Tooling for Ajax-Based Development. Craig R. McClanahan Senior Staff Engineer Sun Microsystems, Inc.

Tooling for Ajax-Based Development. Craig R. McClanahan Senior Staff Engineer Sun Microsystems, Inc. Tooling for Ajax-Based Development Craig R. McClanahan Senior Staff Engineer Sun Microsystems, Inc. 1 Agenda In The Beginning Frameworks Tooling Architectural Approaches Resources 2 In The Beginning 3

More information

Ajax. Ronald J. Glotzbach

Ajax. Ronald J. Glotzbach Ajax Ronald J. Glotzbach What is AJAX? Asynchronous JavaScript and XML Ajax is not a technology Ajax mixes well known programming techniques in an uncommon way Enables web builders to create more appealing

More information

CS WEB TECHNOLOGY

CS WEB TECHNOLOGY CS1019 - WEB TECHNOLOGY UNIT 1 INTRODUCTION 9 Internet Principles Basic Web Concepts Client/Server model retrieving data from Internet HTM and Scripting Languages Standard Generalized Mark up languages

More information

2/6/2012. Rich Internet Applications. What is Ajax? Defining AJAX. Asynchronous JavaScript and XML Term coined in 2005 by Jesse James Garrett

2/6/2012. Rich Internet Applications. What is Ajax? Defining AJAX. Asynchronous JavaScript and XML Term coined in 2005 by Jesse James Garrett What is Ajax? Asynchronous JavaScript and XML Term coined in 2005 by Jesse James Garrett http://www.adaptivepath.com/ideas/essays/archives /000385.php Ajax isn t really new, and isn t a single technology

More information

Abstract. 1. Introduction. 2. AJAX overview

Abstract. 1. Introduction. 2. AJAX overview Asynchronous JavaScript Technology and XML (AJAX) Chrisina Draganova Department of Computing, Communication Technology and Mathematics London Metropolitan University 100 Minories, London EC3 1JY c.draganova@londonmet.ac.uk

More information

AJAX: Asynchronous Event Handling Sunnie Chung

AJAX: Asynchronous Event Handling Sunnie Chung AJAX: Asynchronous Event Handling Sunnie Chung http://adaptivepath.org/ideas/ajax-new-approach-web-applications/ http://stackoverflow.com/questions/598436/does-an-asynchronous-call-always-create-call-a-new-thread

More information

Contents. Demos folder: Demos\14-Ajax. 1. Overview of Ajax. 2. Using Ajax directly. 3. jquery and Ajax. 4. Consuming RESTful services

Contents. Demos folder: Demos\14-Ajax. 1. Overview of Ajax. 2. Using Ajax directly. 3. jquery and Ajax. 4. Consuming RESTful services Ajax Contents 1. Overview of Ajax 2. Using Ajax directly 3. jquery and Ajax 4. Consuming RESTful services Demos folder: Demos\14-Ajax 2 1. Overview of Ajax What is Ajax? Traditional Web applications Ajax

More information

Ajax- XMLHttpResponse. Returns a value such as ArrayBuffer, Blob, Document, JavaScript object, or a DOMString, based on the value of

Ajax- XMLHttpResponse. Returns a value such as ArrayBuffer, Blob, Document, JavaScript object, or a DOMString, based on the value of Ajax- XMLHttpResponse XMLHttpResponse - A Read only field Returns a value such as ArrayBuffer, Blob, Document, JavaScript object, or a DOMString, based on the value of XMLHttpRequest.responseType. This

More information

Web Application Security

Web Application Security Web Application Security Rajendra Kachhwaha rajendra1983@gmail.com September 23, 2015 Lecture 13: 1/ 18 Outline Introduction to AJAX: 1 What is AJAX 2 Why & When use AJAX 3 What is an AJAX Web Application

More information

AJAX and PHP AJAX. Christian Wenz,

AJAX and PHP AJAX. Christian Wenz, AJAX and PHP Christian Wenz, AJAX A Dutch soccer team A cleaner Two characters from Iliad A city in Canada A mountain in Colorado... Asynchronous JavaScript + XML 1 1 What is AJAX?

More information

10.1 Overview of Ajax

10.1 Overview of Ajax 10.1 Overview of Ajax - History - Possibility began with the nonstandard iframe element, which appeared in IE4 and Netscape 4 - An iframe element could be made invisible and could be used to send asynchronous

More information

5/19/2015. Objectives. JavaScript, Sixth Edition. Introduction to the World Wide Web (cont d.) Introduction to the World Wide Web

5/19/2015. Objectives. JavaScript, Sixth Edition. Introduction to the World Wide Web (cont d.) Introduction to the World Wide Web Objectives JavaScript, Sixth Edition Chapter 1 Introduction to JavaScript When you complete this chapter, you will be able to: Explain the history of the World Wide Web Describe the difference between

More information

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery. HTML5/CSS3/JavaScript Programming Course Summary Description This class is designed for students that have experience with basic HTML concepts that wish to learn about HTML Version 5, Cascading Style Sheets

More information

WebDev. Web Design COMBINES A NUMBER OF DISCIPLINES. Web Development Process DESIGN DEVELOPMENT CONTENT MULTIMEDIA

WebDev. Web Design COMBINES A NUMBER OF DISCIPLINES. Web Development Process DESIGN DEVELOPMENT CONTENT MULTIMEDIA WebDev Site Construction is one of the last steps The Site Development Process http://webstyleguide.com Web Design COMBINES A NUMBER OF DISCIPLINES DESIGN CONTENT Interaction Designers User Interface Designers

More information

Programming for Digital Media. Lecture 7 JavaScript By: A. Mousavi and P. Broomhead SERG, School of Engineering Design, Brunel University, UK

Programming for Digital Media. Lecture 7 JavaScript By: A. Mousavi and P. Broomhead SERG, School of Engineering Design, Brunel University, UK Programming for Digital Media Lecture 7 JavaScript By: A. Mousavi and P. Broomhead SERG, School of Engineering Design, Brunel University, UK 1 Topics Ajax (Asynchronous JavaScript and XML) What it is and

More information

Web Programming Paper Solution (Chapter wise)

Web Programming Paper Solution (Chapter wise) What is valid XML document? Design an XML document for address book If in XML document All tags are properly closed All tags are properly nested They have a single root element XML document forms XML tree

More information

Reading How the Web Works

Reading How the Web Works Reading 1.3 - How the Web Works By Jonathan Lane Introduction Every so often, you get offered a behind-the-scenes look at the cogs and fan belts behind the action. Today is your lucky day. In this article

More information

Review. Fundamentals of Website Development. Web Extensions Server side & Where is your JOB? The Department of Computer Science 11/30/2015

Review. Fundamentals of Website Development. Web Extensions Server side & Where is your JOB? The Department of Computer Science 11/30/2015 Fundamentals of Website Development CSC 2320, Fall 2015 The Department of Computer Science Review Web Extensions Server side & Where is your JOB? 1 In this chapter Dynamic pages programming Database Others

More information

Use of PHP for DB Connection. Middle and Information Tier. Middle and Information Tier

Use of PHP for DB Connection. Middle and Information Tier. Middle and Information Tier Use of PHP for DB Connection 1 2 Middle and Information Tier PHP: built in library functions for interfacing with the mysql database management system $id = mysqli_connect(string hostname, string username,

More information

Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX

Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX Duration: 5 Days US Price: $2795 UK Price: 1,995 *Prices are subject to VAT CA Price: CDN$3,275 *Prices are subject

More information

Java Applets, etc. Instructor: Dmitri A. Gusev. Fall Lecture 25, December 5, CS 502: Computers and Communications Technology

Java Applets, etc. Instructor: Dmitri A. Gusev. Fall Lecture 25, December 5, CS 502: Computers and Communications Technology Java Applets, etc. Instructor: Dmitri A. Gusev Fall 2007 CS 502: Computers and Communications Technology Lecture 25, December 5, 2007 CGI (Common Gateway Interface) CGI is a standard for handling forms'

More information

Notes General. IS 651: Distributed Systems 1

Notes General. IS 651: Distributed Systems 1 Notes General Discussion 1 and homework 1 are now graded. Grading is final one week after the deadline. Contract me before that if you find problem and want regrading. Minor syllabus change Moved chapter

More information

Web Programming Paper Solution (Chapter wise)

Web Programming Paper Solution (Chapter wise) Introduction to web technology Three tier/ n-tier architecture of web multitier architecture (often referred to as n-tier architecture) is a client server architecture in which presentation, application

More information

Introduction to Ajax

Introduction to Ajax Introduction to Ajax with Bob Cozzi What is AJAX? Asynchronous JavaScript and XML A J a X Asynchronous data retrieval using the XMLHttpRequest object from JavaScript Data is retrieved from the server as

More information

XML Processing & Web Services. Husni Husni.trunojoyo.ac.id

XML Processing & Web Services. Husni Husni.trunojoyo.ac.id XML Processing & Web Services Husni Husni.trunojoyo.ac.id Based on Randy Connolly and Ricardo Hoar Fundamentals of Web Development, Pearson Education, 2015 Objectives 1 XML Overview 2 XML Processing 3

More information

JavaScript: Introduction, Types

JavaScript: Introduction, Types JavaScript: Introduction, Types Computer Science and Engineering College of Engineering The Ohio State University Lecture 19 History Developed by Netscape "LiveScript", then renamed "JavaScript" Nothing

More information

Client Side JavaScript and AJAX

Client Side JavaScript and AJAX Client Side JavaScript and AJAX Client side javascript is JavaScript that runs in the browsers of people using your site. So far all the JavaScript code we've written runs on our node.js server. This is

More information

Ajax in Oracle JDeveloper

Ajax in Oracle JDeveloper Ajax in Oracle JDeveloper Bearbeitet von Deepak Vohra 1. Auflage 2008. Taschenbuch. xiv, 224 S. Paperback ISBN 978 3 540 77595 9 Format (B x L): 15,5 x 23,5 cm Gewicht: 373 g Weitere Fachgebiete > EDV,

More information

Web Engineering (CC 552)

Web Engineering (CC 552) Web Engineering (CC 552) Introduction Dr. Mohamed Magdy mohamedmagdy@gmail.com Room 405 (CCIT) Course Goals n A general understanding of the fundamentals of the Internet programming n Knowledge and experience

More information

User Interaction: jquery

User Interaction: jquery User Interaction: jquery Assoc. Professor Donald J. Patterson INF 133 Fall 2012 1 jquery A JavaScript Library Cross-browser Free (beer & speech) It supports manipulating HTML elements (DOM) animations

More information

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains an Individual and Group component

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains an Individual and Group component Module 5 JavaScript, AJAX, and jquery Module 5 Contains an Individual and Group component Both are due on Wednesday October 24 th Start early on this module One of the most time consuming modules in the

More information

/ Introduction to XML

/   Introduction to XML Introduction to XML XML stands for Extensible Markup Language. It is a text-based markup language derived from Standard Generalized Markup Language (SGML). XML tags identify the data and are used to store

More information

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains 2 components

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains 2 components Module 5 JavaScript, AJAX, and jquery Module 5 Contains 2 components Both the Individual and Group portion are due on Monday October 30 th Start early on this module One of the most time consuming modules

More information

Programming the World Wide Web by Robert W. Sebesta

Programming the World Wide Web by Robert W. Sebesta Programming the World Wide Web by Robert W. Sebesta Tired Of Rpg/400, Jcl And The Like? Heres A Ticket Out Programming the World Wide Web by Robert Sebesta provides students with a comprehensive introduction

More information

Web Programming/Scripting: PHP and AJAX Refresher

Web Programming/Scripting: PHP and AJAX Refresher CS 312 Internet Concepts Web Programming/Scripting: PHP and AJAX Refresher Dr. Michele Weigle Department of Computer Science Old Dominion University mweigle@cs.odu.edu http://www.cs.odu.edu/~mweigle/cs312-f11

More information

AJAX. Lab. de Bases de Dados e Aplicações Web MIEIC, FEUP 2010/11. Sérgio Nunes

AJAX. Lab. de Bases de Dados e Aplicações Web MIEIC, FEUP 2010/11. Sérgio Nunes AJAX Lab. de Bases de Dados e Aplicações Web MIEIC, FEUP 2010/11 Sérgio Nunes Server calls from web pages using JavaScript call HTTP data Motivation The traditional request-response cycle in web applications

More information

Developing Applications with Java EE 6 on WebLogic Server 12c

Developing Applications with Java EE 6 on WebLogic Server 12c Developing Applications with Java EE 6 on WebLogic Server 12c Duration: 5 Days What you will learn The Developing Applications with Java EE 6 on WebLogic Server 12c course teaches you the skills you need

More information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript CS 4640 Programming Languages for Web Applications JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation

More information

Chapter 9. Web Applications The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill

Chapter 9. Web Applications The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Chapter 9 Web Applications McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter Objectives - 1 Explain the functions of the server and the client in Web programming Create a Web

More information

CNIT 129S: Securing Web Applications. Ch 3: Web Application Technologies

CNIT 129S: Securing Web Applications. Ch 3: Web Application Technologies CNIT 129S: Securing Web Applications Ch 3: Web Application Technologies HTTP Hypertext Transfer Protocol (HTTP) Connectionless protocol Client sends an HTTP request to a Web server Gets an HTTP response

More information

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started Application Development in JAVA Duration Lecture: Specialization x Hours Core Java (J2SE) & Advance Java (J2EE) Detailed Module Part I: Core Java (J2SE) Getting Started What is Java all about? Features

More information

AJAX Programming Chris Seddon

AJAX Programming Chris Seddon AJAX Programming Chris Seddon seddon-software@keme.co.uk 2000-12 CRS Enterprises Ltd 1 2000-12 CRS Enterprises Ltd 2 What is Ajax? "Asynchronous JavaScript and XML" Originally described in 2005 by Jesse

More information

An Introduction to AJAX. By : I. Moamin Abughazaleh

An Introduction to AJAX. By : I. Moamin Abughazaleh An Introduction to AJAX By : I. Moamin Abughazaleh How HTTP works? Page 2 / 25 Classical HTTP Process Page 3 / 25 1. The visitor requests a page 2. The server send the entire HTML, CSS and Javascript code

More information

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

PASS4TEST. IT Certification Guaranteed, The Easy Way!   We offer free update service for one year PASS4TEST IT Certification Guaranteed, The Easy Way! \ http://www.pass4test.com We offer free update service for one year Exam : 9A0-046 Title : Adobe GoLive CS2 ACE Exam Vendors : Adobe Version : DEMO

More information

Delivery Options: Attend face-to-face in the classroom or remote-live attendance.

Delivery Options: Attend face-to-face in the classroom or remote-live attendance. XML Programming Duration: 5 Days Price: $2795 *California residents and government employees call for pricing. Discounts: We offer multiple discount options. Click here for more info. Delivery Options:

More information

CS50 Quiz Review. November 13, 2017

CS50 Quiz Review. November 13, 2017 CS50 Quiz Review November 13, 2017 Info http://docs.cs50.net/2017/fall/quiz/about.html 48-hour window in which to take the quiz. You should require much less than that; expect an appropriately-scaled down

More information

UNIT -II. Language-History and Versions Introduction JavaScript in Perspective-

UNIT -II. Language-History and Versions Introduction JavaScript in Perspective- UNIT -II Style Sheets: CSS-Introduction to Cascading Style Sheets-Features- Core Syntax-Style Sheets and HTML Style Rle Cascading and Inheritance-Text Properties-Box Model Normal Flow Box Layout- Beyond

More information

Connecting with Computer Science Chapter 5 Review: Chapter Summary:

Connecting with Computer Science Chapter 5 Review: Chapter Summary: Chapter Summary: The Internet has revolutionized the world. The internet is just a giant collection of: WANs and LANs. The internet is not owned by any single person or entity. You connect to the Internet

More information

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML UI Course (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) HTML: Introduction The World Wide Web (WWW) and history of HTML Hypertext and Hypertext Markup Language Why HTML Prerequisites Objective

More information

Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand)

Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand) Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand) Code: URL: D101074GC10 View Online The Developing Applications for the Java EE 7 Platform training teaches you how

More information

Distributed Multitiered Application

Distributed Multitiered Application Distributed Multitiered Application Java EE platform uses a distributed multitiered application model for enterprise applications. Logic is divided into components https://docs.oracle.com/javaee/7/tutorial/overview004.htm

More information

Rico AjaxEngine Tutorial

Rico AjaxEngine Tutorial The Rico JavaScript library provides a single JavaScript object, AjaxEngine, for adding Ajax to any HTML page. What is Ajax? Widkipedia has the following definition for Ajax: Traditional web applications

More information

CSC309: Introduction to Web Programming. Lecture 11

CSC309: Introduction to Web Programming. Lecture 11 CSC309: Introduction to Web Programming Lecture 11 Wael Aboulsaadat Servlets+JSP Model 2 Architecture 2 Servlets+JSP Model 2 Architecture = MVC Design Pattern 3 Servlets+JSP Model 2 Architecture Controller

More information

Lesson 5: Multimedia on the Web

Lesson 5: Multimedia on the Web Lesson 5: Multimedia on the Web Learning Targets I can: Define objects and their relationships to multimedia Explain the fundamentals of C, C++, Java, JavaScript, JScript, C#, ActiveX and VBScript Discuss

More information

Exam : 9A Title : Adobe GoLive CS2 ACE Exam. Version : DEMO

Exam : 9A Title : Adobe GoLive CS2 ACE Exam. Version : DEMO Exam : 9A0-046 Title : Adobe GoLive CS2 ACE Exam Version : DEMO 1. Which scripting language is the default for use with ASP, and does NOT require a language specification at the beginning of a Web page's

More information

Credits: Some of the slides are based on material adapted from

Credits: Some of the slides are based on material adapted from 1 The Web, revisited WEB 2.0 marco.ronchetti@unitn.it Credits: Some of the slides are based on material adapted from www.telerik.com/documents/telerik_and_ajax.pdf 2 The old web: 1994 HTML pages (hyperlinks)

More information

Using AJAX to Easily Integrate Rich Media Elements

Using AJAX to Easily Integrate Rich Media Elements 505 Using AJAX to Easily Integrate Rich Media Elements James Monroe Course Developer, WWW.eLearningGuild.com The Problem: How to string together several rich media elements (images, Flash movies, video,

More information

Kyle Rainville Littleton Coin Company

Kyle Rainville Littleton Coin Company Kyle Rainville Littleton Coin Company What is JSON? Javascript Object Notation (a subset of) Data Interchange Format Provides a way for communication between platforms & languages Derived from Javascript

More information

Asynchronous JavaScript + XML (Ajax)

Asynchronous JavaScript + XML (Ajax) Asynchronous JavaScript + XML (Ajax) CSE 190 M (Web Programming), Spring 2008 University of Washington References: w3schools, Wikipedia Except where otherwise noted, the contents of this presentation are

More information

INDEX SYMBOLS See also

INDEX SYMBOLS See also INDEX SYMBOLS @ characters, PHP methods, 125 $ SERVER global array variable, 187 $() function, 176 $F() function, 176-177 elements, Rico, 184, 187 elements, 102 containers,

More information

ver Wfl Adobe lif Sams Teach Yourself Betsy Bruce Robyn Ness SAMS 800 East 96th Street, Indianapolis, Indiana, USA WlM John Ray ^lg^

ver Wfl Adobe lif Sams Teach Yourself Betsy Bruce Robyn Ness SAMS 800 East 96th Street, Indianapolis, Indiana, USA WlM John Ray ^lg^ Betsy Bruce John Ray Robyn Ness Sams Teach Yourself Adobe Wfl lif ver W ^msssi^ mm WlM ^lg^ SAMS 800 East 96th Street, Indianapolis, Indiana, 46240 USA Table of Contents Introduction What Is Dreamweaver

More information

Web Programming. Lecture 11. University of Toronto

Web Programming. Lecture 11. University of Toronto CSC309: Introduction to Web Programming Lecture 11 Wael Aboulsaadat University of Toronto Servlets+JSP Model 2 Architecture University of Toronto 2 Servlets+JSP Model 2 Architecture = MVC Design Pattern

More information

AJAX. Ajax: Asynchronous JavaScript and XML *

AJAX. Ajax: Asynchronous JavaScript and XML * AJAX Ajax: Asynchronous JavaScript and XML * AJAX is a developer's dream, because you can: Read data from a web server - after the page has loaded Update a web page without reloading the page Send data

More information

wemx WebService V1.0

wemx WebService V1.0 wemx WebService 2 wemx WebService WEMX WEBSERVICE... 1 1. WEB SERVICE INTRODUCTION... 6 1.1. SYSTEM PAGE... 6 1.2. USER PAGE... 7 1.3. WEB SERVICE API... 8 2. SYSTEM PAGE PROVIDED BY THE WEB SERVICE...

More information

SSC - Web applications and development Introduction and Java Servlet (I)

SSC - Web applications and development Introduction and Java Servlet (I) SSC - Web applications and development Introduction and Java Servlet (I) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics What will we learn

More information

CGS 3066: Spring 2015 JavaScript Reference

CGS 3066: Spring 2015 JavaScript Reference CGS 3066: Spring 2015 JavaScript Reference Can also be used as a study guide. Only covers topics discussed in class. 1 Introduction JavaScript is a scripting language produced by Netscape for use within

More information

AJAX Programming Overview. Introduction. Overview

AJAX Programming Overview. Introduction. Overview AJAX Programming Overview Introduction Overview In the world of Web programming, AJAX stands for Asynchronous JavaScript and XML, which is a technique for developing more efficient interactive Web applications.

More information

Index. Ray Nicholus 2016 R. Nicholus, Beyond jquery, DOI /

Index. Ray Nicholus 2016 R. Nicholus, Beyond jquery, DOI / Index A addclass() method, 2 addeventlistener, 154, 156 AJAX communication, 20 asynchronous operations, 110 expected and unexpected responses, 111 HTTP, 110 web sockets, 111 AJAX requests DELETE requests,

More information

Dreamweaver MX The Basics

Dreamweaver MX The Basics Chapter 1 Dreamweaver MX 2004 - The Basics COPYRIGHTED MATERIAL Welcome to Dreamweaver MX 2004! Dreamweaver is a powerful Web page creation program created by Macromedia. It s included in the Macromedia

More information

Ajax or AJAX? The acronym AJAX has changed to the term Ajax, which does not represent specific technologies

Ajax or AJAX? The acronym AJAX has changed to the term Ajax, which does not represent specific technologies Introduc)on to Ajax Ajax Theory What is Ajax Ajax is a group of interrelated technologies used to create interac5ve web applica5ons or rich Internet applica5ons. With Ajax, web applica5ons can retrieve

More information