SlideShare a Scribd company logo
AJAX.
XML and JSON
Andrii Siusko
October 2013
AGENDA
What is AJAX? Why do we need it?
HTMLRequest object
Data formats
– XML
• structure and syntax
• basic rules and restrictions
• best practices of use
– JSON
• YAML principles and structure
• basic rules
• best practices
PREREQUISITE
SO WHAT’S THE PROBLEM?
user must wait while new
pages load
POSSIBLE SOLUTION
user can keep interacting
with page while data loads
ASYNCHRONOUS WEB COMMUNICATION
WHAT IS AJAX?
AJAX : Asynchronous JavaScript and XML
 not a programming language; a particular way of using JavaScript
 downloads data from a server in the background
 allows dynamically updating a page without making the user wait
 avoids the "click-wait-refresh" pattern
AJAX is based on internet standards, and uses a combination of:
 XMLHttpRequest object (to exchange data asynchronously with a
server)
 JavaScript/DOM (to display/interact with the information)
 CSS (to style the data)
 XML (often used as the format for transferring data)
COMMUNICATION IN BACKGROUND –
HOW IS IT MADE?
Prerequisite: JavaScript
Create HTTPRequest object
Prepare data to send
Do .send() method
Watch for request status:
– not ok:
• fulfill error handling
– ok: 
• get server reply
• manage it
HTTPREQUEST OBJECT: CREATE
if (window.XMLHttpRequest){
// code for IE7+, Firefox, Chrome, Opera, Safari
ajax = new XMLHttpRequest();
}
else{
// code for IE6, IE5
ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
HTTPREQUEST OBJECT:
HANDLE (METHODS)
.open(method, URL, async,
[userName], [password]);
• method = “GET” || “POST”;
• boolean async;
.send([content]);
.abort();
.getAllResponseHeaders();
• returns all headers as String;
.getResponseHeader(headerName);
• returns all headers as String;
HTTPREQUEST OBJECT:
HANDLE (FIELD)
.onreadystatechange = function {};
• describes what should script do on server response
.readyState
• 0 not initialized; 1 open;
• 2 sending…; 3 receiving…;
• 4 ready
.status; .statusText;
• 200 ok; 404 not found;
• 403 not authorized; …
.responseText; .responseXML
• responseXML could be parsed as DOM element
XMLHTTPREQUEST SECURITY
RESTRICTIONS
• cannot be run from a web page stored on
your hard drive
• can only be run on a web page stored on a
web server
• can only fetch files from the same site
that the page is on*
* 1. <script type="text/javascript“
src=“external_domein“ ></script>
2. Create XDR object:
xdr = new XDomainRequest(); // IE8+
3. easyXDM (Javascript library)
GOT REPLY. WHAT’S NOW?
Get text reply or XML
Parse it (if need)
Use DHTML principles to change existing content
• document.getElementById(ID).innerText || .innerHTML
XML – WHAT IS THIS?
eXtensible Markup Language
– tag based;
– has DOM structure;
languages written in XML specify:
− names of tags in XHTML: h1, div, img, etc.
− names of attributes in XHTML: id/class, src, href, etc.
− rules about how they go together in XHTML: inline vs.
block-level elements
XML – RESTRICTIONS
Should have header and root element;
Tags are case sensitive;
< and & should be encoded
• >, single and double quotes should be encoded too
Tags should be nested properly
The best practice is to use schemata or DTD
XML – RESTRICTIONS
Should have header and root element;
Tags are case sensitive;
< and & should be encoded
• >, single and double quotes should be encoded too
Tags should be nested properly
The best practice is to use schemata or DTD
ANATOMY OF AN XML FILE
<?xml version="1.0" encoding="UTF-8"?> <!-- XML prolog -->
<messages> <!-- root element -->
<id>1</id> <!-- element (“tag") -->
<login>
Tom <!-- content of element -->
</login>
<message lang="engl"> <!-- attribute and its value -->
Hi Nick!
</message>
</messages>
JSON
JavaScript Object Notation (JSON):
− Data format that represents data as a set of
JavaScript objects
− invented by JS guru Douglas Crockford of Yahoo!
− natively supported by all modern browsers (and
libraries to support it in old ones)
− not yet as popular as XML, but steadily rising due
to its simplicity and ease of use
JSON SYNTAX
JSON is object
It can contain:
– “name” : “value” pairs;
– objects
• {
• “name1” : “value1”, // comma required;
• “name2” : “value2”
• }
– arrays: “arr” : [“val1”, “val2”, “val3”]
– // Java-style comments allowed
Any value could be:
• integer • “string”
• true/false/null • object or array
JSON HANDLE
var s =
‘{“name”: “value”,
“arr”: [1,2,33,40,],
“obj”: {“n1”: “v1”, “n2”: “v2”}
}’;
var jsonObj = JSON.parse(s);
// jsonObj.name = “value”;
// jsonObj.arr[2] = 33;
// jsonObj.obj.n2 = “v2”;
REFERENCES
http://google.com
http://www.w3.org/Protocols/rfc2616/rfc2616.html
http://www.w3.org/TR/XMLHttpRequest/
https://github.com/oyvindkinsey/easyXDM#readme
http://msdn.microsoft.com/en-us/library/cc288060(v=vs.85).aspx (XDR)
http://json.org
Thank you!
Andrii Siusko
skype: asyusko
mail: asyusko@gmail.com

More Related Content

What's hot

MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & Introduction
Jerwin Roy
 
Node Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialNode Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js Tutorial
PHP Support
 
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
Benefits of using MongoDB: Reduce Complexity & Adapt to ChangesBenefits of using MongoDB: Reduce Complexity & Adapt to Changes
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
Alex Nguyen
 
Using Webservice in iOS
Using Webservice  in iOS Using Webservice  in iOS
Using Webservice in iOS
Mahboob Nur
 
Node js crash course session 2
Node js crash course   session 2Node js crash course   session 2
Node js crash course session 2
Abdul Rahman Masri Attal
 
Java XML Parsing
Java XML ParsingJava XML Parsing
Java XML Parsing
srinivasanjayakumar
 
Xml parsing
Xml parsingXml parsing
Xml parsing
Malintha Adikari
 
Node js crash course session 5
Node js crash course   session 5Node js crash course   session 5
Node js crash course session 5
Abdul Rahman Masri Attal
 
Introduction to JSON & AJAX
Introduction to JSON & AJAXIntroduction to JSON & AJAX
Introduction to JSON & AJAX
Collaboration Technologies
 
Comparison with storing data using NoSQL(CouchDB) and a relational database.
Comparison with storing data using NoSQL(CouchDB) and a relational database.Comparison with storing data using NoSQL(CouchDB) and a relational database.
Comparison with storing data using NoSQL(CouchDB) and a relational database.
eross77
 
Internet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web TechnologyInternet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web Technology
Ayes Chinmay
 
Mongo db basics
Mongo db basicsMongo db basics
Mongo db basics
Harischandra M K
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
NexThoughts Technologies
 
Xml
XmlXml
[Mas 500] Data Basics
[Mas 500] Data Basics[Mas 500] Data Basics
[Mas 500] Data Basics
rahulbot
 
Connecting to a REST API in iOS
Connecting to a REST API in iOSConnecting to a REST API in iOS
Connecting to a REST API in iOS
gillygize
 
Scala with mongodb
Scala with mongodbScala with mongodb
Scala with mongodb
Knoldus Inc.
 
Json
Json Json
Sql Server 2016 and JSON
Sql Server 2016 and JSONSql Server 2016 and JSON
Sql Server 2016 and JSON
Greg McMurray
 
Difference between xml and json
Difference between xml and jsonDifference between xml and json
Difference between xml and json
Umar Ali
 

What's hot (20)

MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & Introduction
 
Node Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialNode Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js Tutorial
 
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
Benefits of using MongoDB: Reduce Complexity & Adapt to ChangesBenefits of using MongoDB: Reduce Complexity & Adapt to Changes
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
 
Using Webservice in iOS
Using Webservice  in iOS Using Webservice  in iOS
Using Webservice in iOS
 
Node js crash course session 2
Node js crash course   session 2Node js crash course   session 2
Node js crash course session 2
 
Java XML Parsing
Java XML ParsingJava XML Parsing
Java XML Parsing
 
Xml parsing
Xml parsingXml parsing
Xml parsing
 
Node js crash course session 5
Node js crash course   session 5Node js crash course   session 5
Node js crash course session 5
 
Introduction to JSON & AJAX
Introduction to JSON & AJAXIntroduction to JSON & AJAX
Introduction to JSON & AJAX
 
Comparison with storing data using NoSQL(CouchDB) and a relational database.
Comparison with storing data using NoSQL(CouchDB) and a relational database.Comparison with storing data using NoSQL(CouchDB) and a relational database.
Comparison with storing data using NoSQL(CouchDB) and a relational database.
 
Internet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web TechnologyInternet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-7) [XML and AJAX] | NIC/NIELIT Web Technology
 
Mongo db basics
Mongo db basicsMongo db basics
Mongo db basics
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 
Xml
XmlXml
Xml
 
[Mas 500] Data Basics
[Mas 500] Data Basics[Mas 500] Data Basics
[Mas 500] Data Basics
 
Connecting to a REST API in iOS
Connecting to a REST API in iOSConnecting to a REST API in iOS
Connecting to a REST API in iOS
 
Scala with mongodb
Scala with mongodbScala with mongodb
Scala with mongodb
 
Json
Json Json
Json
 
Sql Server 2016 and JSON
Sql Server 2016 and JSONSql Server 2016 and JSON
Sql Server 2016 and JSON
 
Difference between xml and json
Difference between xml and jsonDifference between xml and json
Difference between xml and json
 

Similar to Ajax xml json

Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Marco Gralike
 
Jdom how it works & how it opened the java process
Jdom how it works & how it opened the java processJdom how it works & how it opened the java process
Jdom how it works & how it opened the java process
Hicham QAISSI
 
Introduction to AJAX
Introduction to AJAXIntroduction to AJAX
Introduction to AJAX
Abzetdin Adamov
 
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
Marco Gralike
 
XML
XMLXML
AD102 - Break out of the Box
AD102 - Break out of the BoxAD102 - Break out of the Box
AD102 - Break out of the Box
Karl-Henry Martinsson
 
Synapseindia dot net development web applications with ajax
Synapseindia dot net development  web applications with ajaxSynapseindia dot net development  web applications with ajax
Synapseindia dot net development web applications with ajax
Synapseindiappsdevelopment
 
Attacks against Microsoft network web clients
Attacks against Microsoft network web clients Attacks against Microsoft network web clients
Attacks against Microsoft network web clients
Positive Hack Days
 
Html css workshop, lesson 0, how browsers work
Html css workshop, lesson 0, how browsers workHtml css workshop, lesson 0, how browsers work
Html css workshop, lesson 0, how browsers work
Albino Tonnina
 
JavaScripts & jQuery
JavaScripts & jQueryJavaScripts & jQuery
JavaScripts & jQuery
Asanka Indrajith
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScript
koppenolski
 
Attack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaAttack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and Kibana
Prajal Kulkarni
 
Ajax workshop
Ajax workshopAjax workshop
Ajax workshop
WBUTTUTORIALS
 
Ajax
AjaxAjax
Introduction to Ajax programming
Introduction to Ajax programmingIntroduction to Ajax programming
Introduction to Ajax programming
Fulvio Corno
 
Ajax Introduction
Ajax IntroductionAjax Introduction
Ajax Introduction
Oliver Cai
 
Unit3wt
Unit3wtUnit3wt
Unit3wt
vamsi krishna
 
Unit3wt
Unit3wtUnit3wt
Unit3wt
vamsitricks
 
AJAX Workshop Notes
AJAX Workshop NotesAJAX Workshop Notes
AJAX Workshop Notes
Pamela Fox
 
Ajax
AjaxAjax

Similar to Ajax xml json (20)

Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
 
Jdom how it works & how it opened the java process
Jdom how it works & how it opened the java processJdom how it works & how it opened the java process
Jdom how it works & how it opened the java process
 
Introduction to AJAX
Introduction to AJAXIntroduction to AJAX
Introduction to AJAX
 
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
 
XML
XMLXML
XML
 
AD102 - Break out of the Box
AD102 - Break out of the BoxAD102 - Break out of the Box
AD102 - Break out of the Box
 
Synapseindia dot net development web applications with ajax
Synapseindia dot net development  web applications with ajaxSynapseindia dot net development  web applications with ajax
Synapseindia dot net development web applications with ajax
 
Attacks against Microsoft network web clients
Attacks against Microsoft network web clients Attacks against Microsoft network web clients
Attacks against Microsoft network web clients
 
Html css workshop, lesson 0, how browsers work
Html css workshop, lesson 0, how browsers workHtml css workshop, lesson 0, how browsers work
Html css workshop, lesson 0, how browsers work
 
JavaScripts & jQuery
JavaScripts & jQueryJavaScripts & jQuery
JavaScripts & jQuery
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScript
 
Attack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaAttack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and Kibana
 
Ajax workshop
Ajax workshopAjax workshop
Ajax workshop
 
Ajax
AjaxAjax
Ajax
 
Introduction to Ajax programming
Introduction to Ajax programmingIntroduction to Ajax programming
Introduction to Ajax programming
 
Ajax Introduction
Ajax IntroductionAjax Introduction
Ajax Introduction
 
Unit3wt
Unit3wtUnit3wt
Unit3wt
 
Unit3wt
Unit3wtUnit3wt
Unit3wt
 
AJAX Workshop Notes
AJAX Workshop NotesAJAX Workshop Notes
AJAX Workshop Notes
 
Ajax
AjaxAjax
Ajax
 

Recently uploaded

Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 

Recently uploaded (20)

Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 

Ajax xml json

  • 1. AJAX. XML and JSON Andrii Siusko October 2013
  • 2. AGENDA What is AJAX? Why do we need it? HTMLRequest object Data formats – XML • structure and syntax • basic rules and restrictions • best practices of use – JSON • YAML principles and structure • basic rules • best practices
  • 4. SO WHAT’S THE PROBLEM? user must wait while new pages load
  • 5. POSSIBLE SOLUTION user can keep interacting with page while data loads
  • 7. WHAT IS AJAX? AJAX : Asynchronous JavaScript and XML  not a programming language; a particular way of using JavaScript  downloads data from a server in the background  allows dynamically updating a page without making the user wait  avoids the "click-wait-refresh" pattern AJAX is based on internet standards, and uses a combination of:  XMLHttpRequest object (to exchange data asynchronously with a server)  JavaScript/DOM (to display/interact with the information)  CSS (to style the data)  XML (often used as the format for transferring data)
  • 8. COMMUNICATION IN BACKGROUND – HOW IS IT MADE? Prerequisite: JavaScript Create HTTPRequest object Prepare data to send Do .send() method Watch for request status: – not ok: • fulfill error handling – ok:  • get server reply • manage it
  • 9. HTTPREQUEST OBJECT: CREATE if (window.XMLHttpRequest){ // code for IE7+, Firefox, Chrome, Opera, Safari ajax = new XMLHttpRequest(); } else{ // code for IE6, IE5 ajax = new ActiveXObject("Microsoft.XMLHTTP"); }
  • 10. HTTPREQUEST OBJECT: HANDLE (METHODS) .open(method, URL, async, [userName], [password]); • method = “GET” || “POST”; • boolean async; .send([content]); .abort(); .getAllResponseHeaders(); • returns all headers as String; .getResponseHeader(headerName); • returns all headers as String;
  • 11. HTTPREQUEST OBJECT: HANDLE (FIELD) .onreadystatechange = function {}; • describes what should script do on server response .readyState • 0 not initialized; 1 open; • 2 sending…; 3 receiving…; • 4 ready .status; .statusText; • 200 ok; 404 not found; • 403 not authorized; … .responseText; .responseXML • responseXML could be parsed as DOM element
  • 12. XMLHTTPREQUEST SECURITY RESTRICTIONS • cannot be run from a web page stored on your hard drive • can only be run on a web page stored on a web server • can only fetch files from the same site that the page is on* * 1. <script type="text/javascript“ src=“external_domein“ ></script> 2. Create XDR object: xdr = new XDomainRequest(); // IE8+ 3. easyXDM (Javascript library)
  • 13. GOT REPLY. WHAT’S NOW? Get text reply or XML Parse it (if need) Use DHTML principles to change existing content • document.getElementById(ID).innerText || .innerHTML
  • 14. XML – WHAT IS THIS? eXtensible Markup Language – tag based; – has DOM structure; languages written in XML specify: − names of tags in XHTML: h1, div, img, etc. − names of attributes in XHTML: id/class, src, href, etc. − rules about how they go together in XHTML: inline vs. block-level elements
  • 15. XML – RESTRICTIONS Should have header and root element; Tags are case sensitive; < and & should be encoded • >, single and double quotes should be encoded too Tags should be nested properly The best practice is to use schemata or DTD
  • 16. XML – RESTRICTIONS Should have header and root element; Tags are case sensitive; < and & should be encoded • >, single and double quotes should be encoded too Tags should be nested properly The best practice is to use schemata or DTD
  • 17. ANATOMY OF AN XML FILE <?xml version="1.0" encoding="UTF-8"?> <!-- XML prolog --> <messages> <!-- root element --> <id>1</id> <!-- element (“tag") --> <login> Tom <!-- content of element --> </login> <message lang="engl"> <!-- attribute and its value --> Hi Nick! </message> </messages>
  • 18. JSON JavaScript Object Notation (JSON): − Data format that represents data as a set of JavaScript objects − invented by JS guru Douglas Crockford of Yahoo! − natively supported by all modern browsers (and libraries to support it in old ones) − not yet as popular as XML, but steadily rising due to its simplicity and ease of use
  • 19. JSON SYNTAX JSON is object It can contain: – “name” : “value” pairs; – objects • { • “name1” : “value1”, // comma required; • “name2” : “value2” • } – arrays: “arr” : [“val1”, “val2”, “val3”] – // Java-style comments allowed Any value could be: • integer • “string” • true/false/null • object or array
  • 20. JSON HANDLE var s = ‘{“name”: “value”, “arr”: [1,2,33,40,], “obj”: {“n1”: “v1”, “n2”: “v2”} }’; var jsonObj = JSON.parse(s); // jsonObj.name = “value”; // jsonObj.arr[2] = 33; // jsonObj.obj.n2 = “v2”;
  • 22. Thank you! Andrii Siusko skype: asyusko mail: asyusko@gmail.com