Asynchronous Javascript And XML

Slides:



Advertisements
Similar presentations
1 CGICGI Common Gateway Interface Server-side Programming Lecture.
Advertisements

INTRODUCTION The Group WEB BROWSER FOR RELATION Goals.
WHAT IS AJAX? Zack Sheppard [zts2101] WHIM April 19, 2011.
Cloud Computing Lecture #7 Introduction to Ajax Jimmy Lin The iSchool University of Maryland Wednesday, October 15, 2008 This work is licensed under a.
Creating your website Using Plain HTML. What is HTML? ► Web pages are authored in HyperText Markup Language (HTML) ► Plain text is marked up with tags,
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
JQuery CS 268. What is jQuery? From their web site:
JSON (JavaScript Object Notation).  A lightweight data-interchange format  A subset of the object literal notation of JavaScript (or ECMA-262).  A.
Chris Pinski.  History  What is Ajax  Who uses Ajax  Underlying Technologies  SE Aspect  Common Problems  Conclusion.
User Interface Design using jQuery Mobile CIS 136 Building Mobile Apps 1.
Introduction to AJAX AJAX Keywords: JavaScript and XML
CS 4720 RESTfulness and AJAX CS 4720 – Web & Mobile Systems.
Web application architecture
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
AJAX محمد احمدی نیا 2 Of 27 What is AJAX?  AJAX = Asynchronous JavaScript and XML.  AJAX is not a new programming language, but.
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
Web Technology Introduction AJAXAJAX. AJAX Outline  What is AJAX?  Benefits  Real world examples  How it works  Code review  Samples.
Representing data with XML SE-2030 Dr. Mark L. Hornick 1.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
AJAX James Kahng. Congrats Jack Guo for Angular entryentry This week’s coding challenge at end of talk.
AJAX Asynchronous JavaScript and XML 1. AJAX Outline What is AJAX? Benefits Real world examples How it works 2.
SE-2840 Dr. Mark L. Hornick 1 Introduction to Ajax Asynchronous Javascript And XML.
AJAX. Ajax  $.get  $.post  $.getJSON  $.ajax  json and xml  Looping over data results, success and error callbacks.
CHAPTER 8 AJAX & JSON WHAT IS AJAX? Ajax lets you…
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
Dave Salinas. What is XML? XML stands for eXtensible Markup Language Markup language, like HTML HTML was designed to display data, whereas XML was designed.
October 7 th, 2010 SDU Webship. What did we learn last week? jQuery makes it really easy to select elements and do stuff with them. jQuery can process.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
JQUERY AND AJAX
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.
Introduction to AJAX Pat Morin COMP Outline What is AJAX? – History – Uses – Pros and Cons An XML HTTP Transaction – Creating an XMLHTTPRequest.
4.01 How Web Pages Work.
Web Programming Language
Web API - Introduction AJAX, Spring Data REST SoftUni Team Web API
JavaScript and Ajax (Ajax Tutorial)
Not a Language but a series of techniques
AJAX AJAX = Asynchronous JavaScript and XML.
Data Virtualization Tutorial… CORS and CIS
AJAX and REST.
XMLHttp Object.
Application with Cross-Platform GUI
AJAX.
AJAX.
PHP / MySQL Introduction
CSE 154 Lecture 22: AJAX.
Web Browser server client 3-Tier Architecture Apache web server PHP
Ajax and JSON (jQuery part 2)
jQuery form submission
ISC440: Web Programming 2 AJAX
HTML5 AJAX & JSON APIs
JavaScript & jQuery AJAX.
Secure Web Programming
HTTP GET vs POST SE-2840 Dr. Mark L. Hornick.
MIS JavaScript and API Workshop (Part 3)
Introduction to AJAX and JSON
Ajax with XML 23-Feb-19.
Ajax with XML 27-Feb-19.
Chengyu Sun California State University, Los Angeles
AJAX CS-422 Dick Steflik.
Chengyu Sun California State University, Los Angeles
Introduction to AJAX and JSON
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
4.01 How Web Pages Work.
Client-Server Model: Requesting a Web Page
Chengyu Sun California State University, Los Angeles
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
PHP and JSON Topics Review JSON.
Presentation transcript:

Asynchronous Javascript And XML Introduction to Ajax Asynchronous Javascript And XML SE-2840 Dr. Mark L. Hornick

HTTP is a transaction-based communication protocol Each HTTP request generates a response A browser may send a GET request for a (HTML) page. The server responds by sending it, and the browser then displays it HTTP request: “get me a page” HTTP response: “here is the page” Web Browser Web Server SE-2840 Dr. Mark L. Hornick

Ajax is a methodology for requesting a HTTP response from the server that does not involve receiving an entire HTML web page For example, the browser requests just the data needed to update part of a web page (for example, the contents of a <table>) AJAX request: “give me the latest list of users” AJAX response: collection of users Web Browser Web Server After receiving the response, the browser incorporates the results into the current page being displayed (using JavaScript) SE-2840 Dr. Mark L. Hornick

Ajax requests can easily be handled via the jQuery .ajax() function: type : "GET", // request via HTTP GET url : "http://localhost:8080/CoinFlipTimes/AllData", // the url of the resource returning the Ajax response data : null, // any addition parameters go here crossDomain:true,// cross-origin request? Then set to true async: true, // the default; false for synchronous dataType : "json", // we want a JSON response success : handleSuccess, // the function to call on success error : handleError // the function to call if an error occurs }); If used synchronously, all other javascript code on the webpage will be suspended, since the .ajax() function will execute on the primary thread. If used asynchronously, the request will be offloaded to a worker thread, so the .ajax call will not block SE-2840 Dr. Mark L. Hornick

The big question What format does Ajax use to represent the data it returns? Hint: Asynchronous Javascript And XML But we really don’t use XML too much anymore (it’s so 1995) CS-422 Dr. Mark L. Hornick

JSON – JavaScript Object Notation JSON took hold around 2005/2006 and quickly replaced XML Part of the JavaScript specification, but is really a language-independent data format JSON XML SE2840 Dr. Mark L. Hornick

Scenario Consider a Java collection of Students: List<Student> students; where public class Student { String firstname; String lastname; int id; String program; } SE2840 Dr. Mark L. Hornick

Here is a JSON portable collection of Students: { “students”: [ { “firstname”:“Bill”, “lastname:“Bored”, “id”:“1111”, “program”:“SE” }, { “firstname”:“Bob”, “lastname:“Sledd”, “id”:“1114”, “program”:“CE” } ] SE2840 Dr. Mark L. Hornick

Here an equivalent XML representation: <?xml version="1.0" encoding="ISO-8859-1"?> <student_list> <student> <firstname>Bill</firstname> <lastname>Bored</lastname> <id>1111</id> <program>SE</program> </student> <firstname>Bob</firstname> <lastname>Sledd</lastname> <id>1112</id> <program>CE</program> </student_list> Note that the XML representation is “heavier” than the JSON representation (and also more difficult to interpret) SE2840 Dr. Mark L. Hornick

JSON data is syntactically just plain old Javascript! { “students”: [ { “firstname”:“Bill”, “lastname:“Bored”, “id”:“1111”, “program”:“SE” }, { “firstname”:“Bob”, “lastname:“Sled”, “id”:“1114”, “program”:“CE” } ] var firstname = response.students[0].firstname; // result is “Bill” SE2840 Dr. Mark L. Hornick

Security issues with Ajax CS-422 Dr. Mark L. Hornick