SlideShare a Scribd company logo
The Document Object Model
(DOM)
An introduction to the concept
Presented By Syed Moosa kaleem
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
"The Document Object Model is
a platform- and language-neutral interface
that will allow programs and scripts
to dynamically access and update
the content, structure and style of documents.
The document can be further processed
and the results of that processing
can be incorporated
back into the presented page."
—World Wide Web Consortium (W3C)
"A tree of nodes"
• A document is represented as a tree of
nodes of various types.
• Many nodes have 'child' nodes (and any child has a direct
"parent").
• A child is a node. Any node may have "children."
• The "sibling of a node is a node that is on the same level or line,
neither above it or below it.
An idea to understand
<div>
<p> This is a <em>new</em> paragraph in an HTML document.
</p>
</div>
The <p>is a child of the <div>.
The <em> is a child of the <p>.
Introduction to JavaScript
Programming
What is JavaScript?
• Interpreted programming or scripting language from Netscape.
• Easier to code than the compiled languages like C and C++.
• Lightweight and most commonly used script in web pages.
• Allow client-side user to interact and create dynamic pages.
• Cross-platform and object-oriented scripting language.
• Most popular programming language in the world.
• High level, dynamic and untyped programming language.
• Standardized in the ECMAScript language specification.
• Used for shorter programs
• Takes longer time to process than compiled languages.
JavaScript Variables
• There are two types of variables: local and global. You declare local variables
using the var keyword and global variables without using the var keyword.
• With the var keyword the variable is considered local because it cannot be
accessed anywhere outside the scope of the place you declare it.
• For example, declaring a local variable inside a function, it cannot be accessed
outside of that function, which makes it local to that function.
• Declaring the same variable without the var keyword, it is accessible
throughout the entire script, not only within that function. Which makes it
global within script tag.
• Declaring a local variable
var num = 10;
• To access the value of the num variable at another point in the script, you
simply reference the variable by name Ex:
document.write("The value of num is: "+ num);
JavaScript Operators
• You need operators when performing any operation in the
JavaScript language.
• Operations include addition, subtraction, comparison, and so
on. There are four types of operators in the JavaScript
language.
• Arithmetic.
• Assignment .
• Comparison .
• Logical
Arrays
• Arrays are similar to variables, but they can hold multiple values.
• There is no limit to the amount or type of data that you can store in a
JavaScript array.
• We can access any value of any item in an array at any time after
declaring it.
• Arrays can hold any data type in the JavaScript language.
• Arrays can store only similar data in any one array.
• Storing similar values in an array
• var colors new Array("orange", ' 'blue", " red", "brown");
var shapes new Array("circle", "square", "triangle", " pentagon");
• Accessing values in an array is easy, but there is a catch. Arrays always start
with an ID of O, rather than 1.
• To access an array item you must use its ID, which refers to the item's
position in the array.
Functions
• Functions are containers for script that is only to be executed by an
event or a call to the function.
• Functions do not execute when the browser initially loads and
executes the script that is included in a web page.
• The purpose of a function is to contain script that has a task so that
you then have the ability to execute that script and run that task at
any time.
• Structuring a simple function
var num 10;
function changeVariableValue() {
num -11;
changeVariableValue();
document.write("num is: "+ num); }
Using JavaScript in HTML code
<!DOCTYPE html>
<html>
<body>
<p>A typical arithmetic operation takes two numbers and produces a new number.</p>
<p id="demo"></p>
<script>
var x = 100 + 50;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
Now it’s time for jQuery
introduction
What is jQuery?
• JavaScript library.
• Cross-browser support.
• Aimed for client-side scripting.
• Released in 2006.
• Most popular JS library today
• FOSS (Free and Open Source Software).
• www.jquery.com
jQuery features
• DOM elements: select, modify .
• Events.
• CSS handling
• Flashy effects
• Ajax
• Very easy to use!
Examples
• $(“div ") Selects all divs
• $(".myClass") Selects all items with myClass class
• $("#myld") Selects all items with myld id (should be just one!)
• $("div.myClass") Selects all divs with myClass class.
• $("div.myClass").append(“<p>Text appended</p>”); Appends
paragraph
• $("#myld").css({font-size:15px});
Test page
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
</body>
</html>
jQuery Event Methods
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
</body>
</html>
jQuery - AJAX Introduction
• AJAX = Asynchronous JavaScript and XML.
• AJAX is the art of exchanging data with a server, and updating parts of
a web page - without reloading the whole page.
• Examples of applications using AJAX: Gmail, Google Maps, Youtube,
and Facebook tabs.
• jQuery provides several methods for AJAX functionality.
• With the jQuery AJAX methods, you can request text, HTML, XML, or
JSON from a remote server using both HTTP Get and HTTP Post - And
you can load the external data directly into the selected HTML
elements of your web page!
jQuery Ajax Example
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").load("demo_test.txt");
});
});
</script>
</head>
<body>
<div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div>
<button>Get External Content</button>
</body>
</html>
jQuery Effects - Animation
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("div").animate({left: '250px'});
});
});
</script>
</head>
<body>
<button>Start Animation</button>
<p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position
property of the element to relative, fixed, or absolute!</p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;"></div>
</body>
</html>
AJAX Introduction
• AJAX = Asynchronous JavaScript And XML.
• AJAX is not a programming language.
• AJAX is a developer's dream, because you can:
• Update a web page without reloading the page
• Request data from a server - after the page has loaded
• Receive data from a server - after the page has loaded
• Send data to a server - in the background
Real-Life Examples of AJAX
• Google Maps
- http://maps.google.com/
• Google Suggest
http :/ /www.google.com/
• Gmail
- http://gmail.com/
AJAX Basics
• AJAX uses XMLHttpRequest
• JavaScript communicates directly with the server, through
the JavaScript XMLHttpRequest object .
• With an XMLHTTPRequest, a web page can make a
request to, and get a response from a web server - without
reloading the page.
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
Ajax Example
<!DOCTYPE html>
<html>
<body>
<h1>The XMLHttpRequest Object</h1>
<button type="button" onclick="loadDoc()">Request data</button>
<p id="demo"></p>
<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = this.responseText;
}
};
xhttp.open("GET", "demo_get.asp", true);
xhttp.send();
} </script>
</body>
</html>
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
Cross Domain Ajax
• A common problem for developers is a browser to refuse access to a
remote resource. Usually, this happens when you execute AJAX cross
domain request using jQuery or plain XMLHttpRequest.
Introduction to JSON
• What is JSON?
• JSON stands for JavaScript Object Notation. JSON objects are used for
transferring data between server and client.
• JSON is a subset of JavaScript. ( ECMA-262 ).
• Language Independent, means it can work well with most of the modern
programming language
• Text-based, human readable data exchange format
• Light-weight. Easier to get and load the requested data quickly.
• Easy to parse.
• JSON is very stable
• official Internet media type for JSON is application/json.
• JSON Is Not XML.
• JSON is a simple, common representation of data.
JSON Syntax
• { "name":"John" }
• JSON Uses JavaScript Syntax
• Because JSON syntax is derived from JavaScript object notation, very
little extra software is needed to work with JSON within JavaScript.
• var person = { "name":"John", "age":31, "city":"New York" };
JSON Data Types
• In JSON, values must be one of the following data types:
• a string
• a number
• an object (JSON object)
• an array
• a boolean
• null
• JSON Strings
• { "name":"John" }
• JSON Numbers
• { "age":30 }
• JSON Objects
• {
"employee":{ "name":"John", "age":30, "city":"New York" }
}
• JSON Arrays
• {
"employees":[ "John", "Anna", "Peter" ]
}
• JSON Booleans
• { "sale":true }
• Accessing Object Values
• myObj = { "name":"John", "age":30, "car":null };
x = myObj.name;
JSON.parse()
• A common use of JSON is to exchange data to/from a web server.
• When receiving data from a web server, the data is always a string.
• Parse the data with JSON.parse(), and the data becomes a JavaScript object.
• Example
• <!DOCTYPE html>
• <html>
• <body>
• <h2>Create Object from JSON String</h2>
• <p id="demo"></p>
• <script>
• var obj = JSON.parse('{ "name":"John", "age":30, "city":"New York"}');
• document.getElementById("demo").innerHTML = obj.name + ", " + obj.age;
• </script>
• </body>
• </html>
JSON.stringify()
• A common use of JSON is to exchange data to/from a web server.
• When sending data to a web server, the data has to be a string.
• Convert a JavaScript object into a string with JSON.stringify().
• <!DOCTYPE html>
• <html>
• <body>
• <h2>Create JSON string from a JavaScript object.</h2>
• <p id="demo"></p>
• <script>
• var obj = { "name":"John", "age":30, "city":"New York"};
• var myJSON = JSON.stringify(obj);
• document.getElementById("demo").innerHTML = myJSON;
• </script>
• </body>
• </html>
Thank You!
For more info you can visit my YouTube Channel
EPICOP
https://www.youtube.com/channel/UCILksVrhIlS-pxcFqvFHM4A

More Related Content

What's hot (20)

Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
WebStackAcademy
 
Learn javascript easy steps
Learn javascript easy stepsLearn javascript easy steps
Learn javascript easy steps
prince Loffar
 
JavaScript - Chapter 7 - Advanced Functions
 JavaScript - Chapter 7 - Advanced Functions JavaScript - Chapter 7 - Advanced Functions
JavaScript - Chapter 7 - Advanced Functions
WebStackAcademy
 
jQuery - Chapter 3 - Effects
jQuery - Chapter 3 - Effects  jQuery - Chapter 3 - Effects
jQuery - Chapter 3 - Effects
WebStackAcademy
 
HTML5 - An introduction
HTML5 - An introductionHTML5 - An introduction
HTML5 - An introduction
Eleonora Ciceri
 
Lecture 5 javascript
Lecture 5 javascriptLecture 5 javascript
Lecture 5 javascript
Mujtaba Haider
 
JavaScript Fundamentals & JQuery
JavaScript Fundamentals & JQueryJavaScript Fundamentals & JQuery
JavaScript Fundamentals & JQuery
Jamshid Hashimi
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
WebStackAcademy
 
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Ayes Chinmay
 
jQuery -Chapter 2 - Selectors and Events
jQuery -Chapter 2 - Selectors and Events jQuery -Chapter 2 - Selectors and Events
jQuery -Chapter 2 - Selectors and Events
WebStackAcademy
 
Ajax presentation
Ajax presentationAjax presentation
Ajax presentation
Bharat_Kumawat
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQuery
Akshay Mathur
 
Java Script basics and DOM
Java Script basics and DOMJava Script basics and DOM
Java Script basics and DOM
Sukrit Gupta
 
Java script
Java scriptJava script
Java script
vishal choudhary
 
Java script basics
Java script basicsJava script basics
Java script basics
Shrivardhan Limbkar
 
JavaScript JQUERY AJAX
JavaScript JQUERY AJAXJavaScript JQUERY AJAX
JavaScript JQUERY AJAX
Makarand Bhatambarekar
 
Javascript
JavascriptJavascript
Javascript
Prashant Kumar
 
Unit 4(it workshop)
Unit 4(it workshop)Unit 4(it workshop)
Unit 4(it workshop)
Dr.Lokesh Gagnani
 
Java script -23jan2015
Java script -23jan2015Java script -23jan2015
Java script -23jan2015
Sasidhar Kothuru
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
Jussi Pohjolainen
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
WebStackAcademy
 
Learn javascript easy steps
Learn javascript easy stepsLearn javascript easy steps
Learn javascript easy steps
prince Loffar
 
JavaScript - Chapter 7 - Advanced Functions
 JavaScript - Chapter 7 - Advanced Functions JavaScript - Chapter 7 - Advanced Functions
JavaScript - Chapter 7 - Advanced Functions
WebStackAcademy
 
jQuery - Chapter 3 - Effects
jQuery - Chapter 3 - Effects  jQuery - Chapter 3 - Effects
jQuery - Chapter 3 - Effects
WebStackAcademy
 
JavaScript Fundamentals & JQuery
JavaScript Fundamentals & JQueryJavaScript Fundamentals & JQuery
JavaScript Fundamentals & JQuery
Jamshid Hashimi
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
WebStackAcademy
 
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Ayes Chinmay
 
jQuery -Chapter 2 - Selectors and Events
jQuery -Chapter 2 - Selectors and Events jQuery -Chapter 2 - Selectors and Events
jQuery -Chapter 2 - Selectors and Events
WebStackAcademy
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQuery
Akshay Mathur
 
Java Script basics and DOM
Java Script basics and DOMJava Script basics and DOM
Java Script basics and DOM
Sukrit Gupta
 

Similar to An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON (20)

UNIT 1 (7).pptx
UNIT 1 (7).pptxUNIT 1 (7).pptx
UNIT 1 (7).pptx
DrDhivyaaCRAssistant
 
BITM3730 10-3.pptx
BITM3730 10-3.pptxBITM3730 10-3.pptx
BITM3730 10-3.pptx
MattMarino13
 
BITM3730 10-4.pptx
BITM3730 10-4.pptxBITM3730 10-4.pptx
BITM3730 10-4.pptx
MattMarino13
 
javaScript and jQuery
javaScript and jQueryjavaScript and jQuery
javaScript and jQuery
Mehrab Hossain
 
AJS UNIT-1 2021-converted.pdf
AJS UNIT-1 2021-converted.pdfAJS UNIT-1 2021-converted.pdf
AJS UNIT-1 2021-converted.pdf
SreeVani74
 
BITM3730Week6.pptx
BITM3730Week6.pptxBITM3730Week6.pptx
BITM3730Week6.pptx
MattMarino13
 
Javascript for web Programming creating and embedding with html
Javascript for web Programming creating and embedding with htmlJavascript for web Programming creating and embedding with html
Javascript for web Programming creating and embedding with html
E.M.G.yadava womens college
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
Núcleo de Electrónica e Informática da Universidade do Algarve
 
Jquery 1
Jquery 1Jquery 1
Jquery 1
Manish Kumar Singh
 
Web Development Introduction to jQuery
Web Development Introduction to jQueryWeb Development Introduction to jQuery
Web Development Introduction to jQuery
Laurence Svekis ✔
 
lecture 6 javascript event and event handling.ppt
lecture 6 javascript event and event handling.pptlecture 6 javascript event and event handling.ppt
lecture 6 javascript event and event handling.ppt
ULADATZ
 
JavaScripts & jQuery
JavaScripts & jQueryJavaScripts & jQuery
JavaScripts & jQuery
Asanka Indrajith
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
rsnarayanan
 
Javascript note for engineering notes.pptx
Javascript note for engineering notes.pptxJavascript note for engineering notes.pptx
Javascript note for engineering notes.pptx
engineeradda55
 
Lecture 10.pdf
Lecture 10.pdfLecture 10.pdf
Lecture 10.pdf
ssuser0890d1
 
Client sidescripting javascript
Client sidescripting javascriptClient sidescripting javascript
Client sidescripting javascript
Selvin Josy Bai Somu
 
JavaScript
JavaScriptJavaScript
JavaScript
Bharti Gupta
 
JavaScript Basics with baby steps
JavaScript Basics with baby stepsJavaScript Basics with baby steps
JavaScript Basics with baby steps
Muhammad khurram khan
 
JSON & AJAX.pptx
JSON & AJAX.pptxJSON & AJAX.pptx
JSON & AJAX.pptx
dyumna2
 
JavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talkJavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talk
Thomas Kjeldahl Nilsson
 
BITM3730 10-3.pptx
BITM3730 10-3.pptxBITM3730 10-3.pptx
BITM3730 10-3.pptx
MattMarino13
 
BITM3730 10-4.pptx
BITM3730 10-4.pptxBITM3730 10-4.pptx
BITM3730 10-4.pptx
MattMarino13
 
AJS UNIT-1 2021-converted.pdf
AJS UNIT-1 2021-converted.pdfAJS UNIT-1 2021-converted.pdf
AJS UNIT-1 2021-converted.pdf
SreeVani74
 
BITM3730Week6.pptx
BITM3730Week6.pptxBITM3730Week6.pptx
BITM3730Week6.pptx
MattMarino13
 
Javascript for web Programming creating and embedding with html
Javascript for web Programming creating and embedding with htmlJavascript for web Programming creating and embedding with html
Javascript for web Programming creating and embedding with html
E.M.G.yadava womens college
 
Web Development Introduction to jQuery
Web Development Introduction to jQueryWeb Development Introduction to jQuery
Web Development Introduction to jQuery
Laurence Svekis ✔
 
lecture 6 javascript event and event handling.ppt
lecture 6 javascript event and event handling.pptlecture 6 javascript event and event handling.ppt
lecture 6 javascript event and event handling.ppt
ULADATZ
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
rsnarayanan
 
Javascript note for engineering notes.pptx
Javascript note for engineering notes.pptxJavascript note for engineering notes.pptx
Javascript note for engineering notes.pptx
engineeradda55
 
JSON & AJAX.pptx
JSON & AJAX.pptxJSON & AJAX.pptx
JSON & AJAX.pptx
dyumna2
 
Ad

Recently uploaded (20)

LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Palo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity FoundationPalo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity Foundation
VICTOR MAESTRE RAMIREZ
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
Create Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent BuilderCreate Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent Builder
DianaGray10
 
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 ADr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr. Jimmy Schwarzkopf
 
AI Trends - Mary Meeker
AI Trends - Mary MeekerAI Trends - Mary Meeker
AI Trends - Mary Meeker
Razin Mustafiz
 
Microsoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentationMicrosoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentation
Digitalmara
 
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
James Anderson
 
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AI Emotional Actors:  “When Machines Learn to Feel and Perform"AI Emotional Actors:  “When Machines Learn to Feel and Perform"
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AkashKumar809858
 
Improving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevExImproving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevEx
Justin Reock
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
UiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build PipelinesUiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build Pipelines
UiPathCommunity
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Jeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software DeveloperJeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software Developer
Jeremy Millul
 
Gihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai TechnologyGihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai Technology
zainkhurram1111
 
The case for on-premises AI
The case for on-premises AIThe case for on-premises AI
The case for on-premises AI
Principled Technologies
 
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk TechniciansOffshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
john823664
 
Securiport - A Border Security Company
Securiport  -  A Border Security CompanySecuriport  -  A Border Security Company
Securiport - A Border Security Company
Securiport
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Palo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity FoundationPalo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity Foundation
VICTOR MAESTRE RAMIREZ
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
Create Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent BuilderCreate Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent Builder
DianaGray10
 
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 ADr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr. Jimmy Schwarzkopf
 
AI Trends - Mary Meeker
AI Trends - Mary MeekerAI Trends - Mary Meeker
AI Trends - Mary Meeker
Razin Mustafiz
 
Microsoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentationMicrosoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentation
Digitalmara
 
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
James Anderson
 
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AI Emotional Actors:  “When Machines Learn to Feel and Perform"AI Emotional Actors:  “When Machines Learn to Feel and Perform"
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AkashKumar809858
 
Improving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevExImproving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevEx
Justin Reock
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
UiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build PipelinesUiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build Pipelines
UiPathCommunity
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Jeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software DeveloperJeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software Developer
Jeremy Millul
 
Gihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai TechnologyGihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai Technology
zainkhurram1111
 
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk TechniciansOffshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
john823664
 
Securiport - A Border Security Company
Securiport  -  A Border Security CompanySecuriport  -  A Border Security Company
Securiport - A Border Security Company
Securiport
 
Ad

An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON

  • 1. The Document Object Model (DOM) An introduction to the concept Presented By Syed Moosa kaleem
  • 6. "The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents. The document can be further processed and the results of that processing can be incorporated back into the presented page." —World Wide Web Consortium (W3C)
  • 7. "A tree of nodes" • A document is represented as a tree of nodes of various types. • Many nodes have 'child' nodes (and any child has a direct "parent"). • A child is a node. Any node may have "children." • The "sibling of a node is a node that is on the same level or line, neither above it or below it.
  • 8. An idea to understand <div> <p> This is a <em>new</em> paragraph in an HTML document. </p> </div> The <p>is a child of the <div>. The <em> is a child of the <p>.
  • 10. What is JavaScript? • Interpreted programming or scripting language from Netscape. • Easier to code than the compiled languages like C and C++. • Lightweight and most commonly used script in web pages. • Allow client-side user to interact and create dynamic pages. • Cross-platform and object-oriented scripting language. • Most popular programming language in the world. • High level, dynamic and untyped programming language. • Standardized in the ECMAScript language specification. • Used for shorter programs • Takes longer time to process than compiled languages.
  • 11. JavaScript Variables • There are two types of variables: local and global. You declare local variables using the var keyword and global variables without using the var keyword. • With the var keyword the variable is considered local because it cannot be accessed anywhere outside the scope of the place you declare it. • For example, declaring a local variable inside a function, it cannot be accessed outside of that function, which makes it local to that function. • Declaring the same variable without the var keyword, it is accessible throughout the entire script, not only within that function. Which makes it global within script tag. • Declaring a local variable var num = 10; • To access the value of the num variable at another point in the script, you simply reference the variable by name Ex: document.write("The value of num is: "+ num);
  • 12. JavaScript Operators • You need operators when performing any operation in the JavaScript language. • Operations include addition, subtraction, comparison, and so on. There are four types of operators in the JavaScript language. • Arithmetic. • Assignment . • Comparison . • Logical
  • 13. Arrays • Arrays are similar to variables, but they can hold multiple values. • There is no limit to the amount or type of data that you can store in a JavaScript array. • We can access any value of any item in an array at any time after declaring it. • Arrays can hold any data type in the JavaScript language. • Arrays can store only similar data in any one array. • Storing similar values in an array • var colors new Array("orange", ' 'blue", " red", "brown"); var shapes new Array("circle", "square", "triangle", " pentagon"); • Accessing values in an array is easy, but there is a catch. Arrays always start with an ID of O, rather than 1. • To access an array item you must use its ID, which refers to the item's position in the array.
  • 14. Functions • Functions are containers for script that is only to be executed by an event or a call to the function. • Functions do not execute when the browser initially loads and executes the script that is included in a web page. • The purpose of a function is to contain script that has a task so that you then have the ability to execute that script and run that task at any time. • Structuring a simple function var num 10; function changeVariableValue() { num -11; changeVariableValue(); document.write("num is: "+ num); }
  • 15. Using JavaScript in HTML code <!DOCTYPE html> <html> <body> <p>A typical arithmetic operation takes two numbers and produces a new number.</p> <p id="demo"></p> <script> var x = 100 + 50; document.getElementById("demo").innerHTML = x; </script> </body> </html>
  • 16. Now it’s time for jQuery introduction
  • 17. What is jQuery? • JavaScript library. • Cross-browser support. • Aimed for client-side scripting. • Released in 2006. • Most popular JS library today • FOSS (Free and Open Source Software). • www.jquery.com
  • 18. jQuery features • DOM elements: select, modify . • Events. • CSS handling • Flashy effects • Ajax • Very easy to use!
  • 19. Examples • $(“div ") Selects all divs • $(".myClass") Selects all items with myClass class • $("#myld") Selects all items with myld id (should be just one!) • $("div.myClass") Selects all divs with myClass class. • $("div.myClass").append(“<p>Text appended</p>”); Appends paragraph • $("#myld").css({font-size:15px});
  • 20. Test page <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").click(function(){ $(this).hide(); }); }); </script> </head> <body> <p>If you click on me, I will disappear.</p> <p>Click me away!</p> <p>Click me too!</p> </body> </html>
  • 21. jQuery Event Methods <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").click(function(){ $(this).hide(); }); }); </script> </head> <body> <p>If you click on me, I will disappear.</p> <p>Click me away!</p> <p>Click me too!</p> </body> </html>
  • 22. jQuery - AJAX Introduction • AJAX = Asynchronous JavaScript and XML. • AJAX is the art of exchanging data with a server, and updating parts of a web page - without reloading the whole page. • Examples of applications using AJAX: Gmail, Google Maps, Youtube, and Facebook tabs. • jQuery provides several methods for AJAX functionality. • With the jQuery AJAX methods, you can request text, HTML, XML, or JSON from a remote server using both HTTP Get and HTTP Post - And you can load the external data directly into the selected HTML elements of your web page!
  • 23. jQuery Ajax Example <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#div1").load("demo_test.txt"); }); }); </script> </head> <body> <div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div> <button>Get External Content</button> </body> </html>
  • 24. jQuery Effects - Animation <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("div").animate({left: '250px'}); }); }); </script> </head> <body> <button>Start Animation</button> <p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p> <div style="background:#98bf21;height:100px;width:100px;position:absolute;"></div> </body> </html>
  • 25. AJAX Introduction • AJAX = Asynchronous JavaScript And XML. • AJAX is not a programming language. • AJAX is a developer's dream, because you can: • Update a web page without reloading the page • Request data from a server - after the page has loaded • Receive data from a server - after the page has loaded • Send data to a server - in the background
  • 26. Real-Life Examples of AJAX • Google Maps - http://maps.google.com/ • Google Suggest http :/ /www.google.com/ • Gmail - http://gmail.com/
  • 27. AJAX Basics • AJAX uses XMLHttpRequest • JavaScript communicates directly with the server, through the JavaScript XMLHttpRequest object . • With an XMLHTTPRequest, a web page can make a request to, and get a response from a web server - without reloading the page.
  • 30. Ajax Example <!DOCTYPE html> <html> <body> <h1>The XMLHttpRequest Object</h1> <button type="button" onclick="loadDoc()">Request data</button> <p id="demo"></p> <script> function loadDoc() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("demo").innerHTML = this.responseText; } }; xhttp.open("GET", "demo_get.asp", true); xhttp.send(); } </script> </body> </html>
  • 33. Cross Domain Ajax • A common problem for developers is a browser to refuse access to a remote resource. Usually, this happens when you execute AJAX cross domain request using jQuery or plain XMLHttpRequest.
  • 34. Introduction to JSON • What is JSON? • JSON stands for JavaScript Object Notation. JSON objects are used for transferring data between server and client. • JSON is a subset of JavaScript. ( ECMA-262 ). • Language Independent, means it can work well with most of the modern programming language • Text-based, human readable data exchange format • Light-weight. Easier to get and load the requested data quickly. • Easy to parse. • JSON is very stable • official Internet media type for JSON is application/json. • JSON Is Not XML. • JSON is a simple, common representation of data.
  • 35. JSON Syntax • { "name":"John" } • JSON Uses JavaScript Syntax • Because JSON syntax is derived from JavaScript object notation, very little extra software is needed to work with JSON within JavaScript. • var person = { "name":"John", "age":31, "city":"New York" };
  • 36. JSON Data Types • In JSON, values must be one of the following data types: • a string • a number • an object (JSON object) • an array • a boolean • null
  • 37. • JSON Strings • { "name":"John" } • JSON Numbers • { "age":30 } • JSON Objects • { "employee":{ "name":"John", "age":30, "city":"New York" } } • JSON Arrays • { "employees":[ "John", "Anna", "Peter" ] } • JSON Booleans • { "sale":true } • Accessing Object Values • myObj = { "name":"John", "age":30, "car":null }; x = myObj.name;
  • 38. JSON.parse() • A common use of JSON is to exchange data to/from a web server. • When receiving data from a web server, the data is always a string. • Parse the data with JSON.parse(), and the data becomes a JavaScript object. • Example • <!DOCTYPE html> • <html> • <body> • <h2>Create Object from JSON String</h2> • <p id="demo"></p> • <script> • var obj = JSON.parse('{ "name":"John", "age":30, "city":"New York"}'); • document.getElementById("demo").innerHTML = obj.name + ", " + obj.age; • </script> • </body> • </html>
  • 39. JSON.stringify() • A common use of JSON is to exchange data to/from a web server. • When sending data to a web server, the data has to be a string. • Convert a JavaScript object into a string with JSON.stringify(). • <!DOCTYPE html> • <html> • <body> • <h2>Create JSON string from a JavaScript object.</h2> • <p id="demo"></p> • <script> • var obj = { "name":"John", "age":30, "city":"New York"}; • var myJSON = JSON.stringify(obj); • document.getElementById("demo").innerHTML = myJSON; • </script> • </body> • </html>
  • 40. Thank You! For more info you can visit my YouTube Channel EPICOP https://www.youtube.com/channel/UCILksVrhIlS-pxcFqvFHM4A