Javascript and AJAX Willem Visser RW334.

Slides:



Advertisements
Similar presentations
JQUERY/AJAX ALIREZA KHATAMIAN DELARAM YAZDANSEPAS.
Advertisements

Javascript and AJAX Willem Visser RW334. Overview Javascript jQuery AngularJS AJAX.
AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 2006.
HTML Markup language - controls appearance and content of a document Javascripts Various HTML tags.
Cloud Computing Lecture #7 Introduction to Ajax Jimmy Lin The iSchool University of Maryland Wednesday, October 15, 2008 This work is licensed under a.
Fundamentals, DOM, Events, AJAX, UI Doncho Minkov Telerik Corporation
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
Prof. James A. Landay University of Washington Spring 2008 Web Interface Design, Prototyping, and Implementation Rich Internet Applications: AJAX, Server.
Agenda What is AJAX? What is jQuery? Demonstration/Tutorial Resources Q&A.
Making AJAX Easy with jQuery Chris Renner Health Systems Analyst Programmer & Informatics Manager VUMC Office of Grants & Contracts Management October.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
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
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
Lecture 9: AJAX, Javascript review..  AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype,
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
Creating Dynamic Webpages
AngularJS AJAX.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Web Programming JAvaScript Ajax Programming Web Programming /38.
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.
Chapter 15 Introducing jQuery Part 1. What is JavaScript? A programming language to add dynamic features to a web page. Client side.
Javascript AJAX HTML WEB SERVER Asynchronous. Javascript HTML events DOM – document object model browser internal view of html page compute.
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.
Open Solutions for a Changing World™ Eddy Kleinjan Copyright 2005, Data Access WordwideNew Techniques for Building Web Applications June 6-9, 2005 Key.
JQuery Fundamentals Introduction Tutorial Videos
What is jQuery?.
JavaScript and Ajax (Ajax Tutorial)
AJAX and JSON Day 8.
CSE 154 Lecture 11: AJAx.
Not a Language but a series of techniques
AJAX and jQuery AJAX AJAX Concepts, XMLHttpRequest, jQuery AJAX: $.ajax(), $.get(), $.post() jQuery AJAX XMLHttpRequest SoftUni Team Technical Trainers.
Data Virtualization Tutorial… CORS and CIS
A little MORE on JavaScript
Lecture 11. Web Standards Continued
JavaScript Event Handling.
AJAX and REST.
Introduction to Web programming
AJAX – Asynchronous JavaScript and XML
Fundamentals, DOM, Events, AJAX, UI
CMPE 280 Web UI Design and Development November 7 Class Meeting
AJAX.
The Cliff Notes Version
Web System & Technology
Jessica Betts, Sophia Pandey, & Ryan Amundson
CSE 154 Lecture 11: AJAx.
MEAN stack L. Grewe.
CSE 154 Lecture 22: AJAX.
Angular (JS): A Framework for Dynamic Web Pages
JavaScript & jQuery AJAX.
Web Programming Language
..
Secure Web Programming
Javascript and JQuery SRM DSC.
E-commerce Applications Development
Document Object Model.
RESTful Web Services.
Chengyu Sun California State University, Los Angeles
AJAX CS-422 Dick Steflik.
Lecture 12: The Fetch Api and AJAx
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
Creating dynamic/interactive web pages
SEEM4540 Tutorial 3 jQuery Wong Wai Chung.
AJAX By Prof. B.A.Khivsara
Software Engineering for Internet Applications
Presentation transcript:

Javascript and AJAX Willem Visser RW334

Overview Javascript jQuery AngularJS AJAX

Javascript Scripting language with dynamic typing Most commonly used for executing inside the browser to interact with the Document Object Model (DOM) Can dynamically update static old HTML Client side validation Popularity faded until AJAX came along now it is the basis of many web development frameworks and even server side (NodeJS) Libraries such as jQuery and AnagularJS

Javascript Example http://www. w3schools. com/js/tryit. asp <html> <head> <script type="text/javascript"> function displayDate() { document.getElementById("demo").innerHTML=Date(); } </script> </head> <body> <h1>My First Web Page</h1> <p id="demo">This is a paragraph.</p> <button type="button" onclick="displayDate()">Display Date</button> </body> </html>

jQuery Nothing more than a Javascript library Makes it much simpler to use JS to manipulate web-related information: html, events, animation and AJAX

jQuery Example http://www. w3schools. com/Jquery/tryit. asp <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"> </script> <script> $(document).ready(function(){ $("p").click(function(){$(this).hide();}); }); </head> <body> <p>If you click on me, I will disappear.</p> <p>Click me away!</p> <p>Click me too!</p> </body> </html>

AngularJS Open Source Javascript framework Maintained by Google and community Model-View-Controller philosophy that tries to improve decoupling and ease of testing Two-way data binding View and Model Changes to either triggers the other to change Includes templates as well JS <<< jQuery <<< AngularJS

AngularJS Example http://viralpatel <html ng-app> <head> <title>Hello World, AngularJS</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script> </head> <body> Write some text: <input type="text" ng-model=”thetext" /> <h1>Hello {{ thetext }}</h1> </body> </html>

AJAX Asynchronous Javascript and XML Client sends asynchronous request to server Client can continue Server responds with data or error Client handles success by displaying data Client handles failure Only part of the page gets refreshed!

JS and AJAX http://html.net/tutorials/javascript/lesson18.php <html> <body> <h1>AJAX Calls - XML Response</h1> <div id="test”> <h2>Click the button to get a list of programming languages</h2> <input type="button" value="Click Me!" onclick="loadXML('text.xml')" /> </div> <script type="text/javascript"> var myRequest; function loadXML(url) { myRequest = new XMLHttpRequest(); myRequest.open("GET", url, true); myRequest.send(null); myRequest.onreadystatechange = getData; } function getData()… </script> </body> </html> <languages> <language>PHP</language> <language>Ruby</language> <language>C#</language> <language>JavaScript</language> </languages>

JS and AJAX http://html.net/tutorials/javascript/lesson18.php function getData() { var myDiv = document.getElementById("test"); if (myRequest.readyState ===4 && myRequest.status === 200) { var languages = myRequest.responseXML.getElementsByTagName("language"); for (var i = 0; i < languages.length; i++) { var paragraph = document.createElement("p"); myDiv.appendChild(paragraph); paragraph.appendChild(document.createTextNode( languages[i].firstChild.data)); } To get this example to run: Start a webserver with python -m SimpleHTTPServer in the directory where the html and xml file is, open a browser to the IP indicated and click on the html file in the listing

jQuery and AJAX (1) <html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></script> </head> <body> <p><a href="#">Click here to fetch HTML content</a></p> <div id="result”> </div> <script type="text/javascript”> $(document).ready(function() { $('a').click(function() { $('#result').load('content.html #content’); }); </script> </body> </html> <div id ="content"> some content </div> <div id ="content1"> some content 1 </div>

jQuery and AJAX (2) $(document).ready(function() { function processData(data) { var resultStr = "”; var items = $(data).find('language'); $(items).each(function(i) { resultStr += $(this).text() + '<br />’; $('#result').html(resultStr); }); } $('a').click(function() { $.get(“text.xml”, processData); });

jQuery and AJAX (3) $(document).ready(function() { function processData(data) { … } function errorAlert(e, jqxhr) { alert("Your request was not successful: " + jqxhr); } $('a').click(function() { $.ajax({type: "GET”, cache: false, url: “text.xml”, dataType: "xml”, contentType: "text/html”, success: processData, error: errorAlert });

AngularJS and AJAX (1) <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script> </head> <body ng-app="myapp”> <div ng-controller="MyController" > <button ng-click="myData.doClick(item, $event)">Send AJAX </button> <br/> <div ng-repeat="item in myData.languages”> {{item.language}} <br> </div> </div> <script> …. </script> </body>

AngularJS and AJAX (1) angular.module("myapp", []) .controller("MyController", function($scope, $http) { $scope.myData = {}; $scope.myData.doClick = function(item, event) { var responsePromise = $http.get("text.json"); responsePromise.success(function(data, status, headers, config) { $scope.myData.languages = data; }); responsePromise.error(function(data, status, headers, config) { alert("AJAX failed!"); } );

AngularJS Main Features Directives <div ng-repeat=“actor in movie”> 2- way Data binding View and Model via $scope Note all still client side though, the server doesn’t get updated until you POST something View will get updated the moment an AJAX call returns and is handled correctly Filtering Very powerful Useful for Search features Single Page Web Applications Just one HTML page but everything changes on it ng-view routes