XML JavaScript Object Notation JSON Cookies Miscellaneous What Javascript can t do. OOP Concepts of JS

Similar documents
INTERNET PROGRAMMING XML

SEEM4570 System Design and Implementation Lecture 03 JavaScript

CSC Web Technologies, Spring Web Data Exchange Formats

Introduction to Web Tech and Programming

JSON is a light-weight alternative to XML for data-interchange JSON = JavaScript Object Notation

markup language carry data define your own tags self-descriptive W3C Recommendation

Core PHP. PHP output mechanism. Introducing. Language basics. Installing & Configuring PHP. Introducing of PHP keywords. Operators & expressions

JSON as an XML Alternative. JSON is a light-weight alternative to XML for datainterchange

So, if you receive data from a server, in JSON format, you can use it like any other JavaScript object.

AJAX ASYNCHRONOUS JAVASCRIPT AND XML. Laura Farinetti - DAUIN

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2017)

Introduction to PHP. Handling Html Form With Php. Decisions and loop. Function. String. Array

/ Introduction to XML

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

PHP Online Training. PHP Online TrainingCourse Duration - 45 Days. Call us: HTML

DevShala Technologies A-51, Sector 64 Noida, Uttar Pradesh PIN Contact us

JavaScript Introduction

PEMROGRAMAN BERORIENTASI OBJECT. Indra Gunawan, ST., M.Kom., CEH., CHFI

Object Oriented Programming

JAVASCRIPT. JavaScript is the programming language of HTML and the Web. JavaScript Java. JavaScript is interpreted by the browser.

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

Web Programming Pre-01A Web Programming Technologies. Aryo Pinandito, ST, M.MT

JAVA MOCK TEST JAVA MOCK TEST II

REST. Web-based APIs

Data formats. { "firstname": "John", "lastname" : "Smith", "age" : 25, "address" : { "streetaddress": "21 2nd Street",

An Introduction to JavaScript & Bootstrap Basic concept used in responsive website development Form Validation Creating templates

Introduction to JSON. Roger Lacroix MQ Technical Conference v

CERTIFICATE IN WEB PROGRAMMING

Principles of Object Oriented Programming. Lecture 4

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

Alpha College of Engineering and Technology. Question Bank

AJAX: The Basics CISC 282 March 25, 2014

CSC 337. JavaScript Object Notation (JSON) Rick Mercer

Kotlin for Android developers

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

Introduction to XML. Chapter 133

Packaging Data for the Web

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

AJAX: The Basics CISC 282 November 22, 2017

Ajax HTML5 Cookies. Sessions 1A and 1B

Object Oriented Programming

COMP9321 Web Application Engineering

Create a Java project named week9

Static Webpage Development

Inheritance and Polymorphism

JavaScript CS 4640 Programming Languages for Web Applications

Your Scripts in My Page: What Could Possibly Go Wrong? Sebastian Lekies / Ben Stock Martin Johns

User Interaction: jquery

C++ Important Questions with Answers

Overview. Introduction. Introduction XML XML. Lecture 16 Introduction to XML. Boriana Koleva Room: C54

Introduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p.

Data Visualization (CIS 468)

Web Engineering (CC 552)

JAVASCRIPT - OBJECTS OVERVIEW

Contents. Acknowledgments

Advanced PHP and MySQL

Inheritance. For example, to zoom in on the deer family (cervid), we could make a tree like the following.

Web development using PHP & MySQL with HTML5, CSS, JavaScript

VistA: a first-class citizen in the JSON-centric future of Health IT

1. Implementation of Inheritance with objects, methods. 2. Implementing Interface in a simple java class. 3. To create java class with polymorphism

Intro to XML. Borrowed, with author s permission, from:

Creating an Online Catalogue Search for CD Collection with AJAX, XML, and PHP Using a Relational Database Server on WAMP/LAMP Server

Data Visualization (DSC 530/CIS )

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

Game Scripting. Overview. Scripting Concepts. Script Interpreters ( Engines ) Scripting Languages

ASP.NET AJAX adds Asynchronous JavaScript and XML. ASP.NET AJAX was up until the fall of 2006 was known by the code-known of Atlas.

INF5750. Introduction to JavaScript and Node.js

DOT NET Syllabus (6 Months)

IAT 355 : Lab 01. Web Basics

AJAX: Introduction CISC 282 November 27, 2018

MongoDB Web Architecture

October 08: Introduction to Web Security

Call: Core&Advanced Java Springframeworks Course Content:35-40hours Course Outline

What is Inheritance?

INTRODUCTION TO.NET. Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.)

Aim behind client server architecture Characteristics of client and server Types of architectures

Web Application Development

Acknowledgments... xix

CST141 Thinking in Objects Page 1

Java SE7 Fundamentals

Javascript. UNIVERSITY OF MASSACHUSETTS AMHERST CMPSCI 120 Fall 2010

API Documentation. Web Application Development. Zsolt Tóth. University of Miskolc. Zsolt Tóth (University of Miskolc) API Documentation / 28

Advanced Java Programming

Lesson 9: Custom JavaScript Objects

Programming II (CS300)

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

16. Objects & JSON. Dr. Dave Parker. Informa;on and the Web, 2014/15

Managing State. Chapter 13

Produced by. Web Development. Eamonn de Leastar Department of Computing, Maths & Physics Waterford Institute of Technology

JAVA OBJECT-ORIENTED PROGRAMMING

OO and Ahh! An Introduction to Object Oriented Programming With PHP. Division 1 Systems. John Valance. Copyright John Valance Division 1 Systems

CSCI 201L Written Exam #1 Fall % of course grade

EXAM Microsoft MTA Software Development Fundamentals. Buy Full Product.

Rico AjaxEngine Tutorial

JavaScript CS 4640 Programming Languages for Web Applications

Introduction Haim Michael. All Rights Reserved.

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

Custom Fields With Virtuemart 2. Simple Custom Fields. Creating a Custom Field Type

Database Applications

An Overview of. Eric Bollens ebollens AT ucla.edu Mobile Web Framework Architect UCLA Office of Information Technology

Transcription:

LECTURE-4 XML JavaScript Object Notation JSON Cookies Miscellaneous What Javascript can t do. OOP Concepts of JS 1

XML EXTENDED MARKUP LANGUAGE XML is a markup language, like HTML Designed to carry data Not to display data XML tags are NOT predefined. Unlike HTML You must define your own tags Self-descriptive Represented in plain text. 2

A SIMPLE EXAMPLE <note> <to>tove</to> <from>jani</from> <heading>reminder</heading> <body>let s meet tomorrow!</body> </note> Note: 1. User defined tags. 2. Self descriptive 3

JSON Text based Very useful in transferring text data over the web Language independent Used in JS, Java, PHP, etc. Provides easy means to Define JS objects Can convert JS objects to strings and vice-versa Different languages have functions for conversion. 4

JSON EXAMPLE var person = { firstname : "John, lastname : "Doe"; age : 50, address : { street : 11 Broadway, city : New York City } }; Can access data of individual fields person.firstname (or) person[firstname] person.lastname (or) person[lastname] person.address.street(or) person.address[street] 5

JSON DATA TYPES A JSON object member can be of type Number String Another JSON object Nested JSON objects Boolean Array Null Values of objects members can be Modified. E.g., person.address[street] = 2 Coumbia Way Deleted E.g., delete person.age; 6

JSON DATA CONVERSION TO STRING JSON object to string conversion var personstring = JSON.stringify(person) JSON string to an JSON object var person = JSON.parse(personString); Useful in sending JS objects over HTTP as strings. 7

JSON VS. XML Similarities Self describing and text based. Have user defined tags (unlike HTML) Nested Can be parsed in many languages Can be fetched using XMLHTTPResponse (AJAX). Differences JSON can be parsed by JS, XML can be parsed by XML parser JSON does not have an end tag (e.g., NO </firstname>) JSON can use arrays JSON is less verbose 8

COOKIES Small amount of information a web server stores on a browser. Cookie structure <name, value> pairs Typically used to Remember login and password User preferences Web sites visited Personalization Location where cookies are stored Different for each browser. Cookies have an expiration time Cookies can be removed 9

COOKIES CONTD. Cookies <name, value> pairs store Name of the cookie Server name and path If the path is /, cookie is valid in the entire domain Expiry Thursday, February 8, 2018 Each web server Can read its OWN cookies when the web page is loaded. NOT cookies of some other web server Can load multiple (up to a finite limit) cookies on each browser. 10

COOKIES CONTD. Cookies are plain text files. can t be used to read other data on the computer. are not executable files Cannot erase data on computer A site can open ONLY cookies it owns Cookies are set using Set-Cookie attribute in HTTP. 11

WHAT JAVASCRIPT CANNOT DO Javascript cannot Read or write files on client (Other than cookies). Close a window it did not open. Access information (cookies or web content) of other web pages. Access databases, without the use of AJAX and a server side script Cannot write files to servers without the help of server side script. 12

OOP FEATURES Main OOP concepts Treat real world entities as objects Has data and methods Importance features of OOP Data encapsulation Inheritance Polymorphism JS supports these OOP features But note: JS is a weakly typed language. Implementation of these features Different from strongly typed languages like C++ and JAVA 13

CREATING JS OBJECTS Create an instance of an object directly p1 = new Object( ); // Create an object directly using new p1.firstname = "John"; // Set data variables p1.lastname = "Doe"; p1.age = 50; p1.eyecolor = "blue ; p1.incrementage = changeage; // Set method p1.incrementage( ); // Call method function changeage( ) // Function definition { this.age++; } Note: There is NO class keyword, as in C++, JAVA 14

CREATING JS OBJECTS COND. Crate using a template use function // Template (class) definition function person (firstname, lastname, age, eyecolor) // Constructor { this.firstname = firstname; } this.lastname = lastname; this.age = age; this.eyecolor = eyecolor; this.incrementage = changeage; // Define a member function // Function definition function changeage( ) { } this.age++; // Creating a new object of person p1 = new person ( David, Miller, 50, brown ); 15

USEFUL JAVASCRIPT OBJECTS String Array Boolean Date Math http://w3schools.com/jsref/ 16

DATA ENCAPSULATION Data encapsulation is achieved using C++: public, private protected Java: public, private JS public accessible to class/external members private accessible to private/privileged members Privileged methods Can access private functions Can access and change private data External methods can access private members of class Something like public access functions of C++, JAVA 17

PUBLIC MEMBERS // Public data member definition function public_fn_eg ( ) { this. publicmember = <value>; } // Public function definition public_fn_eg.prototype.pubfn = function (<params>) { // code } 18

PRIVATE MEMBERS function private_fn_eg ( ) { // private data members var privatemember = <value>; //private functions function privatefunction_1 (<params>) { // code } } var privatefunction_2 = function(<params>) { // code } 19

PRIVILEGED FUNCTIONS function privileged_fn_eg { this.privilegedfn = function( ) { // CAN access private functions // CAN access/change private data } } 20

INHERITANCE Define parent and child template functions as before. To define the inheritance, use child.prototype = new parent; Children do NOT have access to parent s private members. 21

POLYMORPHISM Inherently supported in Javascript Any object calls member function in the most specific template class. Child objects call member functions From the child class if defined in child objects. From the parent class, otherwise. Parent objects calls the function from the parent template class. 22