AJAX. Ajax  $.get  $.post  $.getJSON  $.ajax  json and xml  Looping over data results, success and error callbacks.

Slides:



Advertisements
Similar presentations
Ali Alshowaish w3schools. XML documents use a self-describing and simple syntax: The first line is the XML declaration. It defines the XML version (1.0)
Advertisements

Copyright © Steven W. Johnson
XML Schema Heewon Lee. Contents 1. Introduction 2. Concepts 3. Example 4. Conclusion.
SPECIAL TOPIC XML. Introducing XML XML (eXtensible Markup Language) ◦A language used to create structured documents XML vs HTML ◦XML is designed to transport.
JSON Valery Ivanov.
JSON IDU0075 Sissejuhatus veebiteenustesse.  JSON stands for JavaScript Object Notation  JSON is lightweight text-data interchange format  JSON is.
Sistemi basati su conoscenza XML Prof. M.T. PAZIENZA a.a
Sistemi basati su conoscenza XML Prof. M.T. PAZIENZA a.a
XML(EXtensible Markup Language). XML XML stands for EXtensible Markup Language. XML is a markup language much like HTML. XML was designed to describe.
15-Jul-15 JSON. JSON example “JSON” stands for “JavaScript Object Notation” Despite the name, JSON is a (mostly) language-independent way of specifying.
Introduction to XML Rashmi Kukanur. XML XML stands for Extensible Markup Language XML was designed to carry data XML and HTML designed with different.
Introduce of XML Xiaoling Song CS157A. What is XML? XML stands for EXtensible Markup Language XML stands for EXtensible Markup Language XML is a markup.
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
XML introduction to Ahmed I. Deeb Dr. Anwar Mousa  presenter  instructor University Of Palestine-2009.
 Introduction to XML Introduction to XML  Features of XML Features of XML  Syntax of XML Syntax of XML  Syntax rules of XML document Syntax rules.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Pemrograman Berbasis WEB XML -Aurelio Rahmadian- Sumber: w3cschools.com.
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
RESTful applications Norman White. REST Representational state transfer Key concepts – Client Server architecture built on transferring resources between.
These Questions are copied from
 XML is designed to describe data and to focus on what data is. HTML is designed to display data and to focus on how data looks.  XML is created to structure,
How do I use HTML and XML to present information?.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
XML eXtensible Markup Language. Topics  What is XML  An XML example  Why is XML important  XML introduction  XML applications  XML support CSEB.
Consuming eXtensible Markup Language (XML) feeds.
1 Dr Alexiei Dingli XML Technologies XML. 2 XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry.
WEB APPLICATION DEVELOPMENT For More visit:
Consuming eXtensible Markup Language (XML) feeds.
Lecture 9: AJAX, Javascript review..  AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype,
An Introduction to XML Sandeep Bhattaram
XML Introduction. What is XML? XML stands for eXtensible Markup Language XML stands for eXtensible Markup Language XML is a markup language much like.
What it is and how it works
XML Introduction. Markup Language A markup language must specify What markup is allowed What markup is required How markup is to be distinguished from.
Creating Dynamic Webpages
Submitted To: Ms. Poonam Saini, Asst. Prof., NITTTR Submitted By: Rohit Handa ME (Modular) CSE 2011 Batch.
Web Technologies Lecture 4 XML and XHTML. XML Extensible Markup Language Set of rules for encoding a document in a format readable – By humans, and –
ASHIMA KALRA  INTRODUCTION OF XML INTRODUCTION OF XML  XML FEATURES XML FEATURES  XML SYNTAX XML SYNTAX  XML ELEMENTS XML ELEMENTS  XML ATTRIBUTES.
IS444: Modern software development tools Dr. Azeddine Chikh.
XML. HTML Before you continue you should have a basic understanding of the following: HTML HTML was designed to display data and to focus on how data.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
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.
OVERVIEW AND PARSING JSON. What is JSON JavaScript Object Notation Used to format data Commonly used in Web as a vehicle to describe data being sent between.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
JSON. JSON as an XML Alternative JSON is a light-weight alternative to XML for data- interchange JSON = JavaScript Object Notation It’s really language.
XML Introduction to XML Extensible Markup Language.
JSON (Copied from and from Prof Da Silva) Week 12 Web site:
JavaScript and Ajax Week 10 Web site:
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
XML & JSON. Background XML and JSON are to standard, textual data formats for representing arbitrary data – XML stands for “eXtensible Markup Language”
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.
11 jQuery Web Service Client. 22 Objectives You will be able to Use JSON (JavaScript Object Notation) for communcations between browser and server methods.
WELCOME MIDHUN SUDHAKAR twitter.com/midhunopus in.linkedin.com/pub/midhunsudhakar/86/a65/a9.
XML intro. What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display.
XML BASICS and more…. What is XML? In common:  XML is a standard, simple, self-describing way of encoding both text and data so that content can be processed.
Storing Data.
JSON Crash Course Traversy Media.
Database Systems Week 12 by Zohaib Jan.
Consuming Java Script Object Notation (JSON) feeds
Prepared for Md. Zakir Hossain Lecturer, CSE, DUET Prepared by Miton Chandra Datta
Session V HTML5 APIs - AJAX & JSON
Asynchronous Javascript And XML
HTML Level II (CyberAdvantage)
HTML5 AJAX & JSON APIs
2017, Fall Pusan National University Ki-Joune Li
JavaScript & jQuery AJAX.
What is XML?.
JSON: JavaScript Object Notation
Presentation transcript:

AJAX

Ajax  $.get  $.post  $.getJSON  $.ajax  json and xml  Looping over data results, success and error callbacks

Ajax Topics  Introduction to XML  Introduction to JSON  Converting from XML to JSON  Looking at JSON in a browser plugin  Look at traditional AJAX in javascript  Shortened jQuery form  jQuery Examples with callbacks  Look at looping over data and inspecting results

What is XML?  XML stands for eXtensible Markup Language  It is designed to transport and represent data in a structured text based format  Commonly used in data communications  Can be used to model complex data structures  Used as a building block in Web Services and B2B communication

What is XML?  Used to describe data and not display data  Tags are not predefined  You define your own tags  XML documents are meant to be self descriptive

XML Example John Mary Reminder Don't forget me this weekend!

XML document tree  XML documents form a tree structure

Everyday Italian Giada De Laurentiis Harry Potter J K. Rowling Learning XML Erik T. Ray The root element in the example is. All elements in the document are contained within. The element has 4 children:,,,.

XML Rules  XML must be well formed so all XML elements must have a closing tag  XML tags are case sensitive  XML elements must be properly nested  XML documents must have a root element  XML attribute values must be quoted Tove Jani

Difference between XML and HTML  XML was designed to transport and store data, with a focus on what data is  HTML was designed to display data, with focus on how data looks

XML Exercise  Write an XML document which is a sample of the following hierarchy  Degree with name attribute  Course [multiple]  Lecturer  First Name  LastName   Students [mulitple]  First Name  LastName   Major  Each student should have an id attribute which is their student id

What is JSON?  JavaScript Object Notation  It is a lightweight text-data interchange format  JSON is “self-describing” and easy to understand  JSON is syntax for storing and exchanging text information similar to HTML  It has the advantage over HTML in that it is smaller than XML, faster and easier to parse  It is language and platform independent  Uses javascript syntax

JSON example { "employees": [ { "firstName":"John", "lastName":"Doe" }, { "firstName":"Anna", "lastName":"Smith" }, { "firstName":"Peter", "lastName":"Jones" } ] }

JSON Rules  Data is in name/value pairs  Data is separated by commas  Curly brackets are used to wrap objects  Square brackets are used to enclose arrays  Name-Value Pair  “firstName” : “Mike”  Equivalent to  firstName = “Mike” in javascript

JSON Values  JSON Values can be  A number (integer of floating point)  A string ( in quotes)  A Boolean (true or false)  An array (square brackets)  An object (curly brackets)  null Example: {“firstName” : “Mike”, “lastName” : “Smith”, “age”:20, “isStudent”: true, parents : [ { “firstName” : “Henry”, “lastName” : “Smith” }, { “firstName” : “Mary”, “lastName” : “Smith” } ] }

JSON Objects { "firstName":"John", "lastName":"Doe" } This is equal to the javascript statements firstName = "John" lastName = "Doe"

JSON Arrays { "employees": [ { "firstName":"John", "lastName":"Doe" }, { "firstName":"Anna", "lastName":"Smith" }, { "firstName":"Peter", "lastName":"Jones" } ] }

JSON uses javascript syntax  You can create an array of objects and assign data to it like this: var employees = [ { "firstName":"John", "lastName":"Doe" }, { "firstName":"Anna", "lastName":"Smith" }, { "firstName":"Peter", "lastName": "Jones" } ]; employees[0].firstName // John employees[0][“firstName”]//John

JSON file extension  JSON files typically end in.json  Mime type for JSON text is “application/json”

JSON exercise  Write a JSON Representation of the following hierarchy  Degree with name attribute  Course [multiple]  Lecturer  First Name  LastName   Students [mulitple]  First Name  LastName   Major  Each student should have an id attribute which is their student id

What is AJAX?  Asynchronous Javascript and XML  It is a term that refers to the interaction of a mix of technologies  Javascript  Web browser  Web server  Allows a web page to ask for and receive a response from a web server and then update itself without ever having to load a web page

What does AJAX allow you to do?  Display new HTML content without reloading the page  Submit a form and instantly display the results  Log in without leaving a page  Browse through database information e.g. Amazon

How Ajax Works  XMLHttpRequest object is the core  This is a feature of browsers that allows JavaScript to send information to a web server and receive information in return  Five steps are usually involved 1. Create an instance of the XMLHttpRequest object 2. Use XHR’s open() method to specify what kind of data is being sent and where the data will go 3. Create a callback function to handle the results 4. Send the request 5. Receive the response

Example of Ajax using traditional javascipt  ajax-example.php ajax-example.php  Look at the use of the XML Http Request Object  Also look for the definition of the callback

Same example written in jQuery $(“#result”).load(“/cgi-bin/simple-ajax- example.cgi");

Ajax Security  Cross Domain Ajax calls  The url used in an ajax call must be on the same website (domain) as the page making the call  Web browsers will not allow you to make Ajax requests to other domains  Essentially we do not want one website being able to access data from another website with no trust involved  cross-domain-ajax-call-is-not-allowed provides a good scenario cross-domain-ajax-call-is-not-allowed