SlideShare a Scribd company logo
1 of 21
ARCHANA.M
II-MSC(CS)
DEPARTMENT OF CS & IT
NADAR SARASWATHI COLLEGE OF
ARTS AND SCIENCE
 Usability of web applications has lagged behind that of desktop applications
 Rich Internet Applications (RIAs)
-Web applications that approximate the look, feel and usability of desktop
applications
-Two key attributes—performance and rich GUI
 RIA performance
-Comes from Ajax (Asynchronous JavaScript and XML), which uses client-side
scripting to make web applications more responsive
Ajax applications separate client-side user interaction and server
communication, and run them in parallel, making the delays of server-
side processing more transparent to the user
“Raw” Ajax:
-uses JavaScript to send asynchronous requests to the server,
then updates the page using the DOM
-need to deal directly with cross-browser portability issues,
making it impractical for developing large-scale applications
Portability issues
-Hidden by Ajax toolkits, such as jQuery, ASP.NET Ajax and JSF’s Ajax
capabilities, which provide powerful ready-to-use controls and functions that
enrich web applications and simplify JavaScript coding by making it cross-
browser compatible.
Achieve rich GUI in RIAs with
-JavaScript toolkits, providing powerful ready-to-use controls and
functions that enrich web applications.
 Traditional web applications
-User fills in the form’s fields, then submits the form
-Browser generates a request to the server, which receives the request and processes it
-Server generates and sends a response containing the exact page that the browser will
render
-Browser loads the new page and temporarily makes the browser window blank
-Client waits for the server to respond and reloads the entire page with the data from the
response
In an Ajax application, when the user interacts with a page
-Client creates an XMLHttpRequest object to manage a request
-XMLHttpRequest object sends the request to and awaits the response
from the server
-Requests are asynchronous, allowing the user to continue interacting with
the application while the server processes the request concurrently
-When the server responds, the XMLHttpRequest object that issued the
request invokes a callback function, which typically uses partial page updates to
display the returned data in the existing web page without reloading the entire
page
 Classic HTML registration form
-Sends all of the data to be validated to the server when the user clicks the
Register button
-While the server is validating the data, the user cannot interact with the page
-Server finds invalid data, generates a new page identifying the errors in the
form and sends it back to the client—which renders the page in the browser
-User fixes the errors and clicks the Register button again
-Cycle repeats until no errors are found, then the data is stored on the server
-Entire page reloads every time the user submits invalid data
 Ajax-enabled forms are more interactive
-Entries are validated individually, dynamically as the user enters data into the
fields
-If a problem is found, the server sends an error message that is asynchronously
displayed to inform the user of the problem
-Sending each entry asynchronously allows the user to address invalid entries
quickly, rather than making edits and resubmitting the entire form repeatedly until all
entries are valid
-Asynchronous requests could also be used to fill some fields based on previous
fields’ values (e.g., city based on zip code)
 XMLHttpRequest object
-Resides on the client
-Is the layer between the client and the server that manages asynchronous
requests in Ajax applications
-Supported on most browsers, though they may implement it differently
 To initiate an asynchronous request
-Create an instance of the XMLHttpRequest object
-Use its open method to set up the request, and its send method to initiate the
request
When an Ajax application requests a file from a server, the browser
typically caches that file
-Subsequent requests for the same file can load it from the browser’s
cache
When the third argument to XMLHttpRequest method open is true, the
request is asynchronous
The following figures summarize some of the XMLHttpRequest object’s
properties and methods, respectively.
The properties are crucial to interacting with asynchronous requests.
The methods initialize, configure and send asynchronous requests.
The web application may interacts with a web service to obtain data and
to modify data in a server-side database.
The web application and server communicate with a data format called
JSON (JavaScript Object Notation).
The application executes server-side functions (or APIs) that occurs in
parallel with the user interacting with the web application.
JSON (JavaScript Object Notation)
-Simple way to represent JavaScript objects as strings
-A simpler alternative to XML for passing data between the client
and the server
-API in many programming languages
JSON object
-Represented as a list of property names and values contained in
curly braces
-{ "propertyName1" : value1, "propertyName2": value2 }
Array
-Represented in JSON with square brackets containing a comma-
separated list of values
-Each value in a JSON array can be a string, a number, a JSON
representation of an object, true, false or null
-"array_name“: [ { "propertyName1" : value1, "propertyName2":
value2 }, { "propertyName1" : value1, "propertyName2": value2 } ]
JSON strings
-Easier to create and parse than XML
-Require fewer bytes
-For these reasons, JSON is commonly used to
communicate in client/server interaction
Web service’s functions or APIs may returns a JSON
representation of an object or array of objects.
For example, when the web application requests the list of
names in the address book, the list is returned as a JSON array.
Address-book data formatted in JSON:
[ { "first": "Cheryl", "last": "Black" },
{ "first": "James", "last": "Blue" },
{ "first": "Mike", "last": "Brown" },
{ "first": "Meg", "last": "Gold" } ]
When the XMLHttpRequest object receives the response, it calls the
JSON.parse function, which converts the JSON string into a JavaScript
object
Ajax enabled rich internet applications with xml and json

More Related Content

What's hot

Active Server Page(ASP)
Active Server Page(ASP)Active Server Page(ASP)
Active Server Page(ASP)Keshab Nath
 
Asp .net web form fundamentals
Asp .net web form fundamentalsAsp .net web form fundamentals
Asp .net web form fundamentalsGopal Ji Singh
 
Enterprise java unit-3_chapter-1-jsp
Enterprise  java unit-3_chapter-1-jspEnterprise  java unit-3_chapter-1-jsp
Enterprise java unit-3_chapter-1-jspsandeep54552
 
Enterprise java unit-1_chapter-2
Enterprise java unit-1_chapter-2Enterprise java unit-1_chapter-2
Enterprise java unit-1_chapter-2sandeep54552
 
Application enumeration and launch
Application enumeration and launchApplication enumeration and launch
Application enumeration and launchPraveen Bakka
 
.net training | learn .net | Microsoft dot net Course | Microsoft dot net onl...
.net training | learn .net | Microsoft dot net Course | Microsoft dot net onl....net training | learn .net | Microsoft dot net Course | Microsoft dot net onl...
.net training | learn .net | Microsoft dot net Course | Microsoft dot net onl...Nancy Thomas
 
Enterprise java unit-2_chapter-1
Enterprise  java unit-2_chapter-1Enterprise  java unit-2_chapter-1
Enterprise java unit-2_chapter-1sandeep54552
 
Liftweb
LiftwebLiftweb
LiftwebScalac
 
1. deploying an asp.net web application
1. deploying an asp.net web application1. deploying an asp.net web application
1. deploying an asp.net web applicationPramod Rathore
 
Introduction to React by Ebowe Blessing
Introduction to React by Ebowe BlessingIntroduction to React by Ebowe Blessing
Introduction to React by Ebowe BlessingBlessing Ebowe
 

What's hot (20)

Active Server Page(ASP)
Active Server Page(ASP)Active Server Page(ASP)
Active Server Page(ASP)
 
AJAX
AJAXAJAX
AJAX
 
Ajax
AjaxAjax
Ajax
 
Asp .net web form fundamentals
Asp .net web form fundamentalsAsp .net web form fundamentals
Asp .net web form fundamentals
 
Enterprise java unit-3_chapter-1-jsp
Enterprise  java unit-3_chapter-1-jspEnterprise  java unit-3_chapter-1-jsp
Enterprise java unit-3_chapter-1-jsp
 
Enterprise java unit-1_chapter-2
Enterprise java unit-1_chapter-2Enterprise java unit-1_chapter-2
Enterprise java unit-1_chapter-2
 
Ajax
AjaxAjax
Ajax
 
Asp.net web api
Asp.net web apiAsp.net web api
Asp.net web api
 
Application enumeration and launch
Application enumeration and launchApplication enumeration and launch
Application enumeration and launch
 
.net training | learn .net | Microsoft dot net Course | Microsoft dot net onl...
.net training | learn .net | Microsoft dot net Course | Microsoft dot net onl....net training | learn .net | Microsoft dot net Course | Microsoft dot net onl...
.net training | learn .net | Microsoft dot net Course | Microsoft dot net onl...
 
Enterprise java unit-2_chapter-1
Enterprise  java unit-2_chapter-1Enterprise  java unit-2_chapter-1
Enterprise java unit-2_chapter-1
 
Liftweb
LiftwebLiftweb
Liftweb
 
ASP.NET Lecture 1
ASP.NET Lecture 1ASP.NET Lecture 1
ASP.NET Lecture 1
 
Ajax
Ajax Ajax
Ajax
 
Asp dot net final (2)
Asp dot net   final (2)Asp dot net   final (2)
Asp dot net final (2)
 
1. deploying an asp.net web application
1. deploying an asp.net web application1. deploying an asp.net web application
1. deploying an asp.net web application
 
Angularjs & REST
Angularjs & RESTAngularjs & REST
Angularjs & REST
 
Introduction to React by Ebowe Blessing
Introduction to React by Ebowe BlessingIntroduction to React by Ebowe Blessing
Introduction to React by Ebowe Blessing
 
Anypoint connector basics
Anypoint connector basicsAnypoint connector basics
Anypoint connector basics
 
Batch processing
Batch processingBatch processing
Batch processing
 

Similar to Ajax enabled rich internet applications with xml and json

Similar to Ajax enabled rich internet applications with xml and json (20)

Ajax
AjaxAjax
Ajax
 
Ajax.ppt
Ajax.pptAjax.ppt
Ajax.ppt
 
Ajax
AjaxAjax
Ajax
 
25250716 seminar-on-ajax text
25250716 seminar-on-ajax text25250716 seminar-on-ajax text
25250716 seminar-on-ajax text
 
Ajax tutorial by bally chohan
Ajax tutorial by bally chohanAjax tutorial by bally chohan
Ajax tutorial by bally chohan
 
Ajax Ppt 1
Ajax Ppt 1Ajax Ppt 1
Ajax Ppt 1
 
Mashup
MashupMashup
Mashup
 
jQuery Ajax
jQuery AjaxjQuery Ajax
jQuery Ajax
 
Ajax
AjaxAjax
Ajax
 
AJAX
AJAXAJAX
AJAX
 
Ajax
AjaxAjax
Ajax
 
SynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client librarySynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client library
 
Ajax
AjaxAjax
Ajax
 
WEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptxWEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptx
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Ajax
AjaxAjax
Ajax
 
Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)
 
Ajax.pdf
Ajax.pdfAjax.pdf
Ajax.pdf
 
Unit-5.pptx
Unit-5.pptxUnit-5.pptx
Unit-5.pptx
 
Ajax
AjaxAjax
Ajax
 

More from ArchanaMani2

Software evolution and Verification,validation
Software evolution and Verification,validationSoftware evolution and Verification,validation
Software evolution and Verification,validationArchanaMani2
 
Code scheduling constraints
Code scheduling constraintsCode scheduling constraints
Code scheduling constraintsArchanaMani2
 
Excellence in visulization
Excellence in visulizationExcellence in visulization
Excellence in visulizationArchanaMani2
 
Transaction management
Transaction managementTransaction management
Transaction managementArchanaMani2
 
Topological Sort and BFS
Topological Sort and BFSTopological Sort and BFS
Topological Sort and BFSArchanaMani2
 
Inheritance and overriding
Inheritance  and overridingInheritance  and overriding
Inheritance and overridingArchanaMani2
 

More from ArchanaMani2 (10)

Software evolution and Verification,validation
Software evolution and Verification,validationSoftware evolution and Verification,validation
Software evolution and Verification,validation
 
Code scheduling constraints
Code scheduling constraintsCode scheduling constraints
Code scheduling constraints
 
Excellence in visulization
Excellence in visulizationExcellence in visulization
Excellence in visulization
 
Firewall
FirewallFirewall
Firewall
 
The linux system
The linux systemThe linux system
The linux system
 
Big data
Big dataBig data
Big data
 
Transaction management
Transaction managementTransaction management
Transaction management
 
Topological Sort and BFS
Topological Sort and BFSTopological Sort and BFS
Topological Sort and BFS
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 
Inheritance and overriding
Inheritance  and overridingInheritance  and overriding
Inheritance and overriding
 

Recently uploaded

NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use CasesTechSoup
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of PlayPooky Knightsmith
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MysoreMuleSoftMeetup
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfNirmal Dwivedi
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 

Recently uploaded (20)

NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 

Ajax enabled rich internet applications with xml and json

  • 1. ARCHANA.M II-MSC(CS) DEPARTMENT OF CS & IT NADAR SARASWATHI COLLEGE OF ARTS AND SCIENCE
  • 2.  Usability of web applications has lagged behind that of desktop applications  Rich Internet Applications (RIAs) -Web applications that approximate the look, feel and usability of desktop applications -Two key attributes—performance and rich GUI  RIA performance -Comes from Ajax (Asynchronous JavaScript and XML), which uses client-side scripting to make web applications more responsive
  • 3. Ajax applications separate client-side user interaction and server communication, and run them in parallel, making the delays of server- side processing more transparent to the user “Raw” Ajax: -uses JavaScript to send asynchronous requests to the server, then updates the page using the DOM -need to deal directly with cross-browser portability issues, making it impractical for developing large-scale applications
  • 4. Portability issues -Hidden by Ajax toolkits, such as jQuery, ASP.NET Ajax and JSF’s Ajax capabilities, which provide powerful ready-to-use controls and functions that enrich web applications and simplify JavaScript coding by making it cross- browser compatible. Achieve rich GUI in RIAs with -JavaScript toolkits, providing powerful ready-to-use controls and functions that enrich web applications.
  • 5.  Traditional web applications -User fills in the form’s fields, then submits the form -Browser generates a request to the server, which receives the request and processes it -Server generates and sends a response containing the exact page that the browser will render -Browser loads the new page and temporarily makes the browser window blank -Client waits for the server to respond and reloads the entire page with the data from the response
  • 6. In an Ajax application, when the user interacts with a page -Client creates an XMLHttpRequest object to manage a request -XMLHttpRequest object sends the request to and awaits the response from the server -Requests are asynchronous, allowing the user to continue interacting with the application while the server processes the request concurrently -When the server responds, the XMLHttpRequest object that issued the request invokes a callback function, which typically uses partial page updates to display the returned data in the existing web page without reloading the entire page
  • 7.  Classic HTML registration form -Sends all of the data to be validated to the server when the user clicks the Register button -While the server is validating the data, the user cannot interact with the page -Server finds invalid data, generates a new page identifying the errors in the form and sends it back to the client—which renders the page in the browser -User fixes the errors and clicks the Register button again -Cycle repeats until no errors are found, then the data is stored on the server -Entire page reloads every time the user submits invalid data
  • 8.  Ajax-enabled forms are more interactive -Entries are validated individually, dynamically as the user enters data into the fields -If a problem is found, the server sends an error message that is asynchronously displayed to inform the user of the problem -Sending each entry asynchronously allows the user to address invalid entries quickly, rather than making edits and resubmitting the entire form repeatedly until all entries are valid -Asynchronous requests could also be used to fill some fields based on previous fields’ values (e.g., city based on zip code)
  • 9.  XMLHttpRequest object -Resides on the client -Is the layer between the client and the server that manages asynchronous requests in Ajax applications -Supported on most browsers, though they may implement it differently  To initiate an asynchronous request -Create an instance of the XMLHttpRequest object -Use its open method to set up the request, and its send method to initiate the request
  • 10. When an Ajax application requests a file from a server, the browser typically caches that file -Subsequent requests for the same file can load it from the browser’s cache When the third argument to XMLHttpRequest method open is true, the request is asynchronous
  • 11. The following figures summarize some of the XMLHttpRequest object’s properties and methods, respectively. The properties are crucial to interacting with asynchronous requests. The methods initialize, configure and send asynchronous requests.
  • 12.
  • 13.
  • 14.
  • 15. The web application may interacts with a web service to obtain data and to modify data in a server-side database. The web application and server communicate with a data format called JSON (JavaScript Object Notation). The application executes server-side functions (or APIs) that occurs in parallel with the user interacting with the web application.
  • 16. JSON (JavaScript Object Notation) -Simple way to represent JavaScript objects as strings -A simpler alternative to XML for passing data between the client and the server -API in many programming languages JSON object -Represented as a list of property names and values contained in curly braces -{ "propertyName1" : value1, "propertyName2": value2 }
  • 17. Array -Represented in JSON with square brackets containing a comma- separated list of values -Each value in a JSON array can be a string, a number, a JSON representation of an object, true, false or null -"array_name“: [ { "propertyName1" : value1, "propertyName2": value2 }, { "propertyName1" : value1, "propertyName2": value2 } ]
  • 18. JSON strings -Easier to create and parse than XML -Require fewer bytes -For these reasons, JSON is commonly used to communicate in client/server interaction
  • 19. Web service’s functions or APIs may returns a JSON representation of an object or array of objects. For example, when the web application requests the list of names in the address book, the list is returned as a JSON array.
  • 20. Address-book data formatted in JSON: [ { "first": "Cheryl", "last": "Black" }, { "first": "James", "last": "Blue" }, { "first": "Mike", "last": "Brown" }, { "first": "Meg", "last": "Gold" } ] When the XMLHttpRequest object receives the response, it calls the JSON.parse function, which converts the JSON string into a JavaScript object