SlideShare a Scribd company logo
3
Most read
5
Most read
6
Most read
Introduction to JSON & AJAX
www.collaborationtech.co.in
Bengaluru INDIA
Presentation By
Ramananda M.S Rao
JSON
Content
What is JSON ?
Where JSON is used ?
JSON Data Types and Values
Object
Arrays
Reading JSON data structure
Where JSON is used ?
Data Interchange
JSON vs. XML
JSON in AJAX
XMLHttpRequest
AJAX
POST and GET calls in AJAX
Ajax Methods and Properties
AJAX client Server Interactions
Benefits of Ajax
Current Issues of AJAX
JSONHttpRequest
JSON Limitations
About Us
www.collaborationtech.co.in
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 has no version and No revisions to the JSON grammar.
JSON is very stable
Character Encoding is Strictly UNICODE. Default: UTF-8. Also UTF-16 and
UTF-32 are allowed.
official Internet media type for JSON is application/json.
JSON Is Not XML.
JSON is a simple, common representation of data.
www.collaborationtech.co.in
JSON DATA TYPES AND VALUES
JSON DATA TYPES AND VALUES
Strings
Numbers
Booleans
Objects
Arrays
null
www.collaborationtech.co.in
Object and Arrays
Object
 Objects are unordered containers of key/value pairs
 Objects are wrapped in { }
 , separates key/value pairs
 : separates keys and values
 Keys are strings
 Values are JSON values - struct,record,hashtable,object
Array
 Arrays are ordered sequences of values
 Arrays are wrapped in []
 , separates values
 An implementation can start array indexing at 0 or 1.
www.collaborationtech.co.in
JSON data:
JSON data: It basically has key-value pairs.
var chaitanya = {
"firstName" : "Chaitanya",
"lastName" : "Singh",
"age" : "28"
};
We can access the information out of a JSON object like this:
document.writeln("The name is: " +chaitanya.firstName);
document.writeln("his age is: " + chaitanya.age);
document.writeln("his last name is: "+ chaitanya.lastName);
www.collaborationtech.co.in
JSON data:
object with one member
{
"course-name": "6.470“
}
object with two members (separated by a comma)
{
"course 6 470"
course-name": "6.470",
"units": 6
}
array with 3 elements ["foo", "bar", 12345]
object with an array as a value
{
"course-name": "6.470",
"times": ["12-4","12-4", "12-4"]
}
www.collaborationtech.co.in
JSON data:
objects with objects and arrays
{
John : {
"label":"John",
"data":[[1880,0.081536],[1881,0.08098],[1882,0.078308]]
},
"James": {
"label":"James",
"data":[[1880,0.050053],[1881,0.05025],[1882,0.048278]]
}
}
var a = {
"John":
{
"label":"John",
"data":[[1880,0.081536],[1881,0.08098],[1882,0.078308]]
},
"James":
{
"label":"James",
"data":[[1880,0.050053],[1881,0.05025],[1882,0.048278]]
}
}
www.collaborationtech.co.in
Parsing JSON
To get the value 1880 marked with red color:
o We can use a.John.data[0][0]
JSON.stringify(): Takes a JavaScript object and produces a JSON string from it.
JSON.parse(): Takes a JSON string and parses it to a JavaScript object.
Parsing JSON in JavaScript
Start with a basic JSON string:
var json = '{ "person" : { "age" : 20, "name" : "Jack" } }';
Right now, all JavaScript sees here is a string. It doesn’t know it’s actually JSON. You can
pass it through to JSON.parse() to convert it into a JavaScript object:
var parsed = JSON.parse(json);
console.log(parsed);
This gives you:
{ person: { age: 20, name: 'Jack' } }
It is now a regular JavaScript object and you can access properties, just as you’d expect,
using either notation:
console.log(parsed.person);
console.log(parsed.person["age"]);
www.collaborationtech.co.in
Parsing JSON
You can do the opposite and turn an object into a string:
var json = {
person: {
age: 20,
name: "Jack"
}
}
console.log(JSON.stringify(json));
This gives you a string containing the following:
{"person":{"age":20,"name":"Jack"}}
www.collaborationtech.co.in
Reading JSON data structure
Simple JSON Example
<!DOCTYPE html>
<html>
<body>
<h2>JSON Object Creation in JavaScript</h2>
<p id="demo"></p>
<script>
var text = '{"name":"John Johnson","street":"Oslo West 16","phone":"555 1234567"}';
var obj = JSON.parse(text);
document.getElementById("demo").innerHTML = obj.name + "<br>" + obj.street + "<br>" +
obj.phone;
</script>
</body>
</html>
www.collaborationtech.co.in
AJAX
AJAX, or Asynchronous JavaScript and XML.
 Describes a Web development technique for creating interactive
Web applications using a combination of HTML (or XHTML) and
Cascading Style Sheets for presenting information; Document
Object Model (DOM).
 JavaScript, to dynamically display and interact with the information
presented; and the XMLHttpRequest object to interchange and
manipulate data asynchronously with the Web server.
 It allows for asynchronous communication, Instead of freezing up
until the completeness, the browser can communicate with server
and continue as normal.
www.collaborationtech.co.in
POST and GET calls in AJAX
POST and GET calls in AJAX
GET places arguments in the query string, but POST doesn’t.
No noticeable difference in AJAX - AJAX request does not appear
in the address bar.
GET call in AJAX still has the size limitation on the amount of
data that can be passed.
General principle:
GET method: it is used to retrieve data to display in the page
and the data is not expected to be changed on the server.
POST method: it is used to update information on the server
www.collaborationtech.co.in
Ajax Methods and Properties
Ajax Methods and Properties
Abort() : Aborts the request if it has already been sent.
getAllResponseHeaders() : Returns all the response headers as a string..
getResponseHeader("headerLabel") : Returns the text of a specified
header.
open("method", "URL"[,asyncFlag[, "userName"[,"password"]]]) :
Initializes a request. This method is to be used from JavaScript code;
to initialize a request from native code, use openRequest() instead.
send(content) :Sends the request. If the request is asynchronous (which is
thedefault), this method returns as soon as the request is sent. If the
( ) request is synchronous, this method doesn't return until the response
has arrived.
setRequestHeader("label", "value") : Sets the value of an HTTP request
header
www.collaborationtech.co.in
Example
<!DOCTYPE html>
<head><title>Ajax Test</title>
<script type="text/javascript">
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "hello.txt", true);
xmlHttp.addEventListener("load", ajaxCallback, false);
xmlHttp.send(null);
function ajaxCallback(event){
alert( "Your file contains the text: " + event.target.responseText );
}
</script>
</head>
<body>
</body>
</html>
www.collaborationtech.co.in
Follow us on Social
Facebook: https://www.facebook.com/collaborationtechnologies/
Twitter : https://twitter.com/collaboration09
Google Plus : https://plus.google.com/100704494006819853579
LinkedIn : https://www.linkedin.com/in/ramananda-rao-a2012545
Instagram : https://instagram.com/collaborationtechnologies
YouTube :
https://www.youtube.com/channel/UCm9nK56LRbWSqcYWbzs8CUg
Skype : facebook:ramananda.rao.7
WhatsApp : +91 9886272445
www.collaborationtech.co.in
THANK YOU
About Us

More Related Content

What's hot (20)

PPS
Jsp element
kamal kotecha
 
PPSX
JDBC: java DataBase connectivity
Tanmoy Barman
 
PPTX
Programming in c Arrays
janani thirupathi
 
PPS
Interface
kamal kotecha
 
PPT
Javascript arrays
Hassan Dar
 
PDF
Files in java
Muthukumaran Subramanian
 
PDF
Generics
Ravi_Kant_Sahu
 
PPT
Java awt
Arati Gadgil
 
PDF
Java Course 8: I/O, Files and Streams
Anton Keks
 
PPTX
Array of objects.pptx
RAGAVIC2
 
PDF
Arrays in Java
Naz Abdalla
 
PPTX
University er-diagram
Sanchai Yordprom
 
PDF
javascript objects
Vijay Kalyan
 
PPT
Core java concepts
Ram132
 
PDF
Php array
Nikul Shah
 
PPSX
Collections - Array List
Hitesh-Java
 
PPTX
Data structure and algorithm using java
Narayan Sau
 
PPTX
String in java
Ideal Eyes Business College
 
PPTX
Core java complete ppt(note)
arvind pandey
 
Jsp element
kamal kotecha
 
JDBC: java DataBase connectivity
Tanmoy Barman
 
Programming in c Arrays
janani thirupathi
 
Interface
kamal kotecha
 
Javascript arrays
Hassan Dar
 
Generics
Ravi_Kant_Sahu
 
Java awt
Arati Gadgil
 
Java Course 8: I/O, Files and Streams
Anton Keks
 
Array of objects.pptx
RAGAVIC2
 
Arrays in Java
Naz Abdalla
 
University er-diagram
Sanchai Yordprom
 
javascript objects
Vijay Kalyan
 
Core java concepts
Ram132
 
Php array
Nikul Shah
 
Collections - Array List
Hitesh-Java
 
Data structure and algorithm using java
Narayan Sau
 
Core java complete ppt(note)
arvind pandey
 

Viewers also liked (20)

PDF
Introduction to JSON
Kanda Runapongsa Saikaew
 
PPT
External Data Access with jQuery
Doncho Minkov
 
PPTX
Ajax ppt - 32 slides
Smithss25
 
PPTX
Preprocessor CSS: SASS
Geoffroy Baylaender
 
PDF
'Less' css
Mayur Mohite
 
PPTX
Ajax xml json
Andrii Siusko
 
PDF
JSON and AJAX JumpStart
dominion
 
PPTX
AJAX and JSON
Julie Iskander
 
PPSX
Dynamic webpages using AJAX & JSON
Christiaan Rakowski
 
PDF
Simplify AJAX using jQuery
Siva Arunachalam
 
PPT
Careers In Java Script Ajax - Java Script Ajax Tutorials & Programs by Learni...
S P Jain Institute of Management & Research (SPJIMR)
 
PPT
Inner core of Ajax
Muhammad Junaid Ansari
 
DOCX
Hari Resume
Hari Krishna
 
PPT
Ajax by Examples 2
Yenwen Feng
 
PPTX
Introduction to JavaScript Programming
Collaboration Technologies
 
PDF
08 ajax
Ynon Perek
 
PPTX
Rekayasa web part 3 khaerul anwar
Khaerul Anwar
 
PPTX
An Introduction to the DOM
Mindy McAdams
 
Introduction to JSON
Kanda Runapongsa Saikaew
 
External Data Access with jQuery
Doncho Minkov
 
Ajax ppt - 32 slides
Smithss25
 
Preprocessor CSS: SASS
Geoffroy Baylaender
 
'Less' css
Mayur Mohite
 
Ajax xml json
Andrii Siusko
 
JSON and AJAX JumpStart
dominion
 
AJAX and JSON
Julie Iskander
 
Dynamic webpages using AJAX & JSON
Christiaan Rakowski
 
Simplify AJAX using jQuery
Siva Arunachalam
 
Careers In Java Script Ajax - Java Script Ajax Tutorials & Programs by Learni...
S P Jain Institute of Management & Research (SPJIMR)
 
Inner core of Ajax
Muhammad Junaid Ansari
 
Hari Resume
Hari Krishna
 
Ajax by Examples 2
Yenwen Feng
 
Introduction to JavaScript Programming
Collaboration Technologies
 
08 ajax
Ynon Perek
 
Rekayasa web part 3 khaerul anwar
Khaerul Anwar
 
An Introduction to the DOM
Mindy McAdams
 
Ad

Similar to Introduction to JSON & AJAX (20)

PPTX
Introduction to JSON & AJAX
Raveendra R
 
PPTX
JSON & AJAX.pptx
dyumna2
 
PPTX
Unit-2.pptx
AnujSood25
 
PPT
json.ppt download for free for college project
AmitSharma397241
 
PDF
CS8651 IP Unit 2 pdf regulation -2017 anna university
amrashbhanuabdul
 
PPTX
JSON
Yoga Raja
 
PPTX
Web technologies-course 10.pptx
Stefan Oprea
 
PDF
Intro to JSON
George McKinney
 
PPTX
JSON.pptx
MaheshHirulkar1
 
PPTX
Java script and json
Islam Abdelzaher
 
PPTX
Web Development Course - AJAX & JSON by RSOLUTIONS
RSolutions
 
PPT
Json – java script object notation
Dilip Kumar Gupta
 
PPT
Json - ideal for data interchange
Christoph Santschi
 
PPTX
json.pptx
Anum Zehra
 
PPT
java script json
chauhankapil
 
PPTX
BITM3730Week8.pptx
MattMarino13
 
PDF
Json the-x-in-ajax1588
Ramamohan Chokkam
 
PDF
Basics of JSON (JavaScript Object Notation) with examples
Sanjeev Kumar Jaiswal
 
Introduction to JSON & AJAX
Raveendra R
 
JSON & AJAX.pptx
dyumna2
 
Unit-2.pptx
AnujSood25
 
json.ppt download for free for college project
AmitSharma397241
 
CS8651 IP Unit 2 pdf regulation -2017 anna university
amrashbhanuabdul
 
JSON
Yoga Raja
 
Web technologies-course 10.pptx
Stefan Oprea
 
Intro to JSON
George McKinney
 
JSON.pptx
MaheshHirulkar1
 
Java script and json
Islam Abdelzaher
 
Web Development Course - AJAX & JSON by RSOLUTIONS
RSolutions
 
Json – java script object notation
Dilip Kumar Gupta
 
Json - ideal for data interchange
Christoph Santschi
 
json.pptx
Anum Zehra
 
java script json
chauhankapil
 
BITM3730Week8.pptx
MattMarino13
 
Json the-x-in-ajax1588
Ramamohan Chokkam
 
Basics of JSON (JavaScript Object Notation) with examples
Sanjeev Kumar Jaiswal
 
Ad

More from Collaboration Technologies (16)

PPTX
Introduction to Core Java Programming
Collaboration Technologies
 
PPTX
Introduction to Database SQL & PL/SQL
Collaboration Technologies
 
PPTX
Introduction to Advanced Javascript
Collaboration Technologies
 
PPTX
Introduction to AngularJS
Collaboration Technologies
 
PPTX
Introduction to Bootstrap
Collaboration Technologies
 
PPTX
Introduction to Hibernate Framework
Collaboration Technologies
 
PPTX
Introduction to HTML4
Collaboration Technologies
 
PPTX
Introduction to HTML5
Collaboration Technologies
 
PPTX
Introduction to JPA Framework
Collaboration Technologies
 
PPTX
Introduction to jQuery
Collaboration Technologies
 
PPTX
Introduction to Perl Programming
Collaboration Technologies
 
PPTX
Introduction to PHP
Collaboration Technologies
 
PPTX
Introduction to Python Basics Programming
Collaboration Technologies
 
PPTX
Introduction to Spring Framework
Collaboration Technologies
 
PPTX
Introduction to Struts 2
Collaboration Technologies
 
PPTX
Introduction to Node.JS
Collaboration Technologies
 
Introduction to Core Java Programming
Collaboration Technologies
 
Introduction to Database SQL & PL/SQL
Collaboration Technologies
 
Introduction to Advanced Javascript
Collaboration Technologies
 
Introduction to AngularJS
Collaboration Technologies
 
Introduction to Bootstrap
Collaboration Technologies
 
Introduction to Hibernate Framework
Collaboration Technologies
 
Introduction to HTML4
Collaboration Technologies
 
Introduction to HTML5
Collaboration Technologies
 
Introduction to JPA Framework
Collaboration Technologies
 
Introduction to jQuery
Collaboration Technologies
 
Introduction to Perl Programming
Collaboration Technologies
 
Introduction to PHP
Collaboration Technologies
 
Introduction to Python Basics Programming
Collaboration Technologies
 
Introduction to Spring Framework
Collaboration Technologies
 
Introduction to Struts 2
Collaboration Technologies
 
Introduction to Node.JS
Collaboration Technologies
 

Recently uploaded (20)

PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Python basic programing language for automation
DanialHabibi2
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 

Introduction to JSON & AJAX

  • 1. Introduction to JSON & AJAX www.collaborationtech.co.in Bengaluru INDIA Presentation By Ramananda M.S Rao
  • 2. JSON Content What is JSON ? Where JSON is used ? JSON Data Types and Values Object Arrays Reading JSON data structure Where JSON is used ? Data Interchange JSON vs. XML JSON in AJAX XMLHttpRequest AJAX POST and GET calls in AJAX Ajax Methods and Properties AJAX client Server Interactions Benefits of Ajax Current Issues of AJAX JSONHttpRequest JSON Limitations About Us www.collaborationtech.co.in
  • 3. 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 has no version and No revisions to the JSON grammar. JSON is very stable Character Encoding is Strictly UNICODE. Default: UTF-8. Also UTF-16 and UTF-32 are allowed. official Internet media type for JSON is application/json. JSON Is Not XML. JSON is a simple, common representation of data. www.collaborationtech.co.in
  • 4. JSON DATA TYPES AND VALUES JSON DATA TYPES AND VALUES Strings Numbers Booleans Objects Arrays null www.collaborationtech.co.in
  • 5. Object and Arrays Object  Objects are unordered containers of key/value pairs  Objects are wrapped in { }  , separates key/value pairs  : separates keys and values  Keys are strings  Values are JSON values - struct,record,hashtable,object Array  Arrays are ordered sequences of values  Arrays are wrapped in []  , separates values  An implementation can start array indexing at 0 or 1. www.collaborationtech.co.in
  • 6. JSON data: JSON data: It basically has key-value pairs. var chaitanya = { "firstName" : "Chaitanya", "lastName" : "Singh", "age" : "28" }; We can access the information out of a JSON object like this: document.writeln("The name is: " +chaitanya.firstName); document.writeln("his age is: " + chaitanya.age); document.writeln("his last name is: "+ chaitanya.lastName); www.collaborationtech.co.in
  • 7. JSON data: object with one member { "course-name": "6.470“ } object with two members (separated by a comma) { "course 6 470" course-name": "6.470", "units": 6 } array with 3 elements ["foo", "bar", 12345] object with an array as a value { "course-name": "6.470", "times": ["12-4","12-4", "12-4"] } www.collaborationtech.co.in
  • 8. JSON data: objects with objects and arrays { John : { "label":"John", "data":[[1880,0.081536],[1881,0.08098],[1882,0.078308]] }, "James": { "label":"James", "data":[[1880,0.050053],[1881,0.05025],[1882,0.048278]] } } var a = { "John": { "label":"John", "data":[[1880,0.081536],[1881,0.08098],[1882,0.078308]] }, "James": { "label":"James", "data":[[1880,0.050053],[1881,0.05025],[1882,0.048278]] } } www.collaborationtech.co.in
  • 9. Parsing JSON To get the value 1880 marked with red color: o We can use a.John.data[0][0] JSON.stringify(): Takes a JavaScript object and produces a JSON string from it. JSON.parse(): Takes a JSON string and parses it to a JavaScript object. Parsing JSON in JavaScript Start with a basic JSON string: var json = '{ "person" : { "age" : 20, "name" : "Jack" } }'; Right now, all JavaScript sees here is a string. It doesn’t know it’s actually JSON. You can pass it through to JSON.parse() to convert it into a JavaScript object: var parsed = JSON.parse(json); console.log(parsed); This gives you: { person: { age: 20, name: 'Jack' } } It is now a regular JavaScript object and you can access properties, just as you’d expect, using either notation: console.log(parsed.person); console.log(parsed.person["age"]); www.collaborationtech.co.in
  • 10. Parsing JSON You can do the opposite and turn an object into a string: var json = { person: { age: 20, name: "Jack" } } console.log(JSON.stringify(json)); This gives you a string containing the following: {"person":{"age":20,"name":"Jack"}} www.collaborationtech.co.in
  • 11. Reading JSON data structure Simple JSON Example <!DOCTYPE html> <html> <body> <h2>JSON Object Creation in JavaScript</h2> <p id="demo"></p> <script> var text = '{"name":"John Johnson","street":"Oslo West 16","phone":"555 1234567"}'; var obj = JSON.parse(text); document.getElementById("demo").innerHTML = obj.name + "<br>" + obj.street + "<br>" + obj.phone; </script> </body> </html> www.collaborationtech.co.in
  • 12. AJAX AJAX, or Asynchronous JavaScript and XML.  Describes a Web development technique for creating interactive Web applications using a combination of HTML (or XHTML) and Cascading Style Sheets for presenting information; Document Object Model (DOM).  JavaScript, to dynamically display and interact with the information presented; and the XMLHttpRequest object to interchange and manipulate data asynchronously with the Web server.  It allows for asynchronous communication, Instead of freezing up until the completeness, the browser can communicate with server and continue as normal. www.collaborationtech.co.in
  • 13. POST and GET calls in AJAX POST and GET calls in AJAX GET places arguments in the query string, but POST doesn’t. No noticeable difference in AJAX - AJAX request does not appear in the address bar. GET call in AJAX still has the size limitation on the amount of data that can be passed. General principle: GET method: it is used to retrieve data to display in the page and the data is not expected to be changed on the server. POST method: it is used to update information on the server www.collaborationtech.co.in
  • 14. Ajax Methods and Properties Ajax Methods and Properties Abort() : Aborts the request if it has already been sent. getAllResponseHeaders() : Returns all the response headers as a string.. getResponseHeader("headerLabel") : Returns the text of a specified header. open("method", "URL"[,asyncFlag[, "userName"[,"password"]]]) : Initializes a request. This method is to be used from JavaScript code; to initialize a request from native code, use openRequest() instead. send(content) :Sends the request. If the request is asynchronous (which is thedefault), this method returns as soon as the request is sent. If the ( ) request is synchronous, this method doesn't return until the response has arrived. setRequestHeader("label", "value") : Sets the value of an HTTP request header www.collaborationtech.co.in
  • 15. Example <!DOCTYPE html> <head><title>Ajax Test</title> <script type="text/javascript"> var xmlHttp = new XMLHttpRequest(); xmlHttp.open("GET", "hello.txt", true); xmlHttp.addEventListener("load", ajaxCallback, false); xmlHttp.send(null); function ajaxCallback(event){ alert( "Your file contains the text: " + event.target.responseText ); } </script> </head> <body> </body> </html> www.collaborationtech.co.in
  • 16. Follow us on Social Facebook: https://www.facebook.com/collaborationtechnologies/ Twitter : https://twitter.com/collaboration09 Google Plus : https://plus.google.com/100704494006819853579 LinkedIn : https://www.linkedin.com/in/ramananda-rao-a2012545 Instagram : https://instagram.com/collaborationtechnologies YouTube : https://www.youtube.com/channel/UCm9nK56LRbWSqcYWbzs8CUg Skype : facebook:ramananda.rao.7 WhatsApp : +91 9886272445 www.collaborationtech.co.in THANK YOU