SlideShare a Scribd company logo
1 of 30
Creating Rich Client Web Applications 
with AJAX
Agenda 
• Web Apps: Whats good, whats not 
• What is AJAX and how can AJAX help with the 
bad? 
• Creating simple AJAX applications 
• AJAX endpoints and payloads 
• Using third-party AJAX libraries 
• AJAX security 
• ASP.NET 2.0 client callbacks and Atlas
The Good, Bad and Ugly 
(of Web Applications) Condensed Version 
• The Good 
– Centralized control of the application 
– Easy deployment 
• The Bad 
– Locked into the browser sandbox 
– Loose the “thick-client” experience 
– One way to get data – the browser postback 
• The Ugly 
– Browser compatibility
How does AJAX help? 
• Keep all of the good of thin client 
• Bring the “thick-client” experience much closer to 
the thin client 
• Escape the standard client/server HTTP request 
communications paradigm (the “postback”)
What the heck is AJAX? 
• Asynchronous JavaScript And XML 
– No new technologies here, just a new name 
• Takes advantage of modern uplevel browser features: 
– A client side XML parser 
(on Windows this is generally the Microsoft XML parser) 
• Send data to/receive data from the server outside of the browsers standard 
communications mechanism (eg the postback) 
• Parse and enumerate XML formatted data on the client 
– A rich Document Object Model (DOM) 
• Powerful interaction points between the different elements of your 
webpage, the browser and browser plugins
The standard web client/server 
request processing model 
HTTP/1.1 200 OK 
Date: Fri, 04 Nov 2005 17:17:37 GMT 
Server: Microsoft-IIS/6.0 
P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV 
ONL PHY PRE PUR UNI" 
X-Powered-By: ASP.NET 
X-AspNet-Version: 2.0.50727 
Cache-Control: private 
Content-Type: text/html; charset=utf-8 
Content-Length: 22370 
GET / HTTP/1.1 
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, 
application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* 
Accept-Language: en-us 
Accept-Encoding: gzip, deflate 
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 
2.0.50727) 
Host: www.microsoft.com 
Proxy-Connection: Keep-Alive 
Cookie: MC1=GUID=5cd2d5ca1a1cc54183c10f4bacaa45fa&HASH=cad5&LV=20059&V=3; 
A=I&I=AxUFAAAAAABuCAAAzJInmvNBZzRHm8aAr99x0A!!; msresearch=1 
Browser makes a resource 
request to the server 
<html dir="ltr" lang="en"> 
<head> 
<META http-equiv="Content-Type" content="text/html; charset=utf-8" > 
<!--TOOLBAR_EXEMPT--> 
<meta http-equiv="PICS-Label" content="(PICS-1.1 &quot;http://www.rsac.org/ratingsv01.html&quot; l gen true r (n 0 s 0 v 
0 l 0))" > 
<meta name="KEYWORDS" content="products; headlines; downloads; news; Web site; what's new; solutions; services; 
software; contests; corporate news;" > 
<meta name="DESCRIPTION" content="The entry page to Microsoft's Web site. Find software, solutions, answers, 
support, and Microsoft news." > 
<meta name="MS.LOCALE" content="EN-US" > 
<meta name="CATEGORY" content="home page" > 
<title>Microsoft Corporation</title> 
<base href="http://g.msn.com/mh_mshp/98765" > 
<style type="text/css" media="all"> 
Server processes the request 
and returns a result to the 
browser 
HTTP Request 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 
HTTP Response
Demo 
• A simple HTML postback example
Problems with this model 
• To get any data requires complete round trip to the 
server which is inefficient 
• UI suffers because the entire UI must be refreshed 
as part of the postback, even if it does not change 
(users see the page “flash”) 
• User is blocked from continuing to work until the 
page is returned from the postback
The client/server request 
processing model using AJAX 
GET /AjaxPresentation/AjaxWithHandler/SimpleAjax.ashx?DataRequest=true&val1=2&val2=2 HTTP/1.1 
Accept: */* 
Accept-Language: en-us 
Referer: http://localhost/AjaxPresentation/AjaxWithHandler/SimpleAjax.aspx 
Accept-Encoding: gzip, deflate 
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) 
Host: localhost 
Proxy-Connection: Keep-Alive 
Cookie: .ASPXANONYMOUS=AcYSqWXDsOAzMTgxM2IwZi04YzdiLTQyMWMtYjJiNi0yYWVmNDA5OGY0Njg1; 
ASP.NET_SessionId=rq0avnqjfi5eer45zeq0qdj1 
Server processes the 
request and returns a 
result to the browser 
Browser makes a 
resource request to 
the server 
HTTP Request 
Using XMLHTTP object, an async 
HTTP request is made to the server 
JavaScript callback function 
handles XMLHTTP response 
HTTP Response 
HTTP/1.1 200 OK 
Server: Microsoft-IIS/5.1 
Date: Fri, 04 Nov 2005 17:33:53 GMT 
X-Powered-By: ASP.NET 
X-AspNet-Version: 1.1.4322 
Cache-Control: private 
Content-Type: text/html; charset=utf-8 
Content-Length: 1 
4
AJAX Advantages 
• Send an receive only the data you need 
– Think chatty, not chunky 
• Only update portions of the page that need to be 
updated 
• Asynchronous, so users can continue to work while 
the page is updated, and more data is fetched
Creating Ajax applications 
• Use JavaScript to instantiate the XML parser 
//Works in Mozilla (Firefox) and Safari 
var oXml = new XMLHttpRequest(); 
Works in Internet Explorer 
var oXml = new ActiveXObject("Microsoft.XMLHTTP"); 
• Use the XML object to create a new HTTP request to 
the server: 
oXml.Open("GET", “Endpoint.aspx”, true); 
• Use the XML objects onreadystatechange property to 
assign a client-side callback method
Demo 
• A simple AJAX demo
Side note: Debugging Client Script 
via Internet Explorer 
– Enable script 
debugging 
– Display script error 
notifications 
– Add the “debugger” 
command to your script 
• Mozilla supports 
debugging via 
Venkman debugger 
add-in
AJAX Endpoints 
• Anything that can be accessed via HTTP can serve as 
an AJAX endpoint 
– Standard ASP.NET webpages (*.aspx) 
– HTTP Handlers (*.ashx, or custom extenstions) 
– Web Services (*.asmx) 
– PHP Web Pages 
• Think about endpoint performance 
– ASPX endpoints require a complete page lifecycle to 
execute on each request 
– Handlers and Web Services are much more lightweight 
– Both can access Session, Cache etc
Demo 
• Using Handlers as AJAX endpoints 
• Accessing Session from an Handler
Controlling Asynchronous 
Communications 
• Create timer based operations using JavaScripts 
setInterval command 
• Make sure you control the number of open HTTP 
connections, as well as the polling interval
Demo 
• Adding AJAX Asynchronous polling
AJAX Payloads 
• The AJAX “Payload” is the data returned by the 
HTTP request. 
• Since Ajax is simply a standard HTTP 
request/response, the response payload can be 
anything you like 
• Examples: 
– XML, HTML, Simple Types (number, string), JSON 
• Remember that the actual HTTP payload will always 
be a type of string, so objects must be serialized
Primary Payload Types 
• Two primary types of payloads in AJAX: 
– XML 
• Simple, easy to read format, but you generally must use the MS 
XML Parser and DOM to work with it 
• Native to .NET – easy to create on and transport from the server 
– JSON (JavaScript Object Notation) 
• Slightly more complex 
• Data must be massaged into JSON format 
• Easier to work with once its on the client 
• Either supports complex object serialization
Using XML Payloads 
• Use the XML DOM to examine and manipulate XML 
data on the client 
– ResponseXml property automatically provides a representation 
of data as parsed by the MSXML XMLDOM parser 
– XMLDOM provides complete XML navigation concepts: 
Document, Element, Node 
– Use client side XSLT to transform or format data 
– ParseError object tells you if the returned XML was badly 
formed 
//Works in Mozilla (Firefox) and Safari 
var oXsl = new XSLTProcessor(); 
//Works in Internet Explorer 
var oXsl = new ActiveXObject("MSXML2.DOMDocument");
Demo 
• Parsing AJAX XML payloads 
• Using XSLT with AJAX Payloads
JSON 
• JSON (JavaScript Object Notation) is a lightweight 
data-interchange format. 
• It is easy for humans to read and write. 
• It is easy for machines to parse and generate. 
• Useful as a data-interchange because it can be 
trivially parsed by JavaScript's built in eval() 
procedure. 
var json_data; 
json_data = ""The quick brown fox.""; 
myObject = eval("return " + json_data);
Examples of JSON 
• Object serialized to JSON example 
{"menu": { 
"id": "file", 
"value": "File", 
"popup": { 
"menuitem": [ 
{"value": "New", "onclick": "CreateNewDoc()"}, 
{"value": "Open", "onclick": "OpenDoc()"}, 
{"value": "Close", "onclick": "CloseDoc()"} 
] 
} 
}} 
• The same text expressed as XML: 
<menu id="file" value="File"> 
<popup> 
<menuitem value="New" onclick="CreateNewDoc()" /> 
<menuitem value="Open" onclick="OpenDoc()" /> 
<menuitem value="Close" onclick="CloseDoc()" /> 
</popup> 
</menu>
Other AJAX libraries 
• Server Side Libraries 
– Ajax.NET 
http://ajax.schwarz-interactive.de/csharpsample/default.aspx 
– PHP & ASP 
http://cpaint.sourceforge.net/ 
• Client Side Libraries 
– Google AJAXSLT 
http://goog-ajaxslt.sourceforge.net/ 
– Dojo 
http://dojotoolkit.org/
Ajax.NET 
• Open Source AJAX implementation for .NET 
(Note: while still available, the project is not longer being actively developed) 
• Easy to use. Requires a simple method attribute ( 
[AjaxMethod()]) to expose server side methods as AJAX 
endpoints 
• Automatically uses JSON to transport complex objects like 
DataSets 
• Uses dynamically generated JavaScript to create client side 
proxies for server side objects 
• Supports transport of integers, strings, doubles, booleans, 
DateTime, DataSets, DataTables and primitive types of custom 
classes and arrays 
• Other types supported via Custom Type converters
Demo 
• Using Ajax.NET
AJAX Security 
• HTTPS is your friend 
• Keep sensitive code or data on the server where you 
can control it 
• By default everything is sent clear text over the wire 
(including client side code), and could potentially be 
captured in transit and modified 
• JavaScript has no intrinsic over-the-wire encryption 
support, but you can implement your own encryption 
(search Google for ‘AJAX encryption’)
Client Callbacks 
• New Feature in ASP.NET 2.0 
• Add client-side callbacks to your web pages or server 
controls 
• Executes in the context of the current page 
– Allows you to access existing control state on the server 
during the callback process 
– Keeps you from having to pass as much data back 
• Not as flexible in setting endpoints, and passing 
arguments
Atlas 
• Microsofts next generation AJAX framework 
– Cross browser compatible 
• Includes both declarative and imperative programming 
models 
– Code in vanilla JavaScript, or use the Atlas “tag” 
programming model 
• Attempts to bring JavaScript to a first class language 
– Uses abstraction layers to add familiar programming 
constructs like Types, Enumerations, Class Inheritance 
– Also uses abstraction layers to abstract cross browser 
problems 
• Includes a number of controls for common functionality
Declarative Atlas 
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005" xmlns:wiki="wiki"> 
<components> 
<label targetElement="loadingMsg1"> 
<bindings> 
<binding dataContext="documentsSource1" dataPath="isReady" property="visible" transform="Invert"/> 
</bindings> 
</label> 
<textBox targetElement="<%= navCategoryID.ClientID %>" /> 
<textBox targetElement="<%= navDefaultDocumentTitle.ClientID %>"/> 
<textBox targetElement="recurseSubfolders1"/> 
<dataSource id="documentsSource1" serviceURL="<%= ResolveUrl("~/WebServices/DocumentWebService.asmx") %>"> 
<bindings> 
<binding dataContext="<%= navCategoryID.ClientID %>" dataPath="text" property="selectParameters" propertyKey="categoryID"/> 
<binding dataContext="<%= navDefaultDocumentTitle.ClientID %>" dataPath="text" property="selectParameters“ 
propertyKey="defaultDocumentTitle"/> 
<binding dataContext="recurseSubfolders1" dataPath="text" property="selectParameters" propertyKey="strRecurseSubfolders"/> 
</bindings> 
</dataSource>

More Related Content

What's hot

Learn Ajax here
Learn Ajax hereLearn Ajax here
Learn Ajax herejarnail
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajaxNir Elbaz
 
Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat ClientPaul Klipp
 
Ajax presentation
Ajax presentationAjax presentation
Ajax presentationBharat_Kumawat
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITCarol McDonald
 
Introduction to ajax
Introduction  to  ajaxIntroduction  to  ajax
Introduction to ajaxPihu Goel
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 
AJAX - An introduction
AJAX - An introductionAJAX - An introduction
AJAX - An introductionEleonora Ciceri
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
HTML5 - An introduction
HTML5 - An introductionHTML5 - An introduction
HTML5 - An introductionEleonora Ciceri
 
Excellent rest using asp.net web api
Excellent rest using asp.net web apiExcellent rest using asp.net web api
Excellent rest using asp.net web apiMaurice De Beijer [MVP]
 
Tips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC ApplicationsTips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC ApplicationsSarvesh Kushwaha
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesWebStackAcademy
 

What's hot (20)

Jquery Ajax
Jquery AjaxJquery Ajax
Jquery Ajax
 
Learn Ajax here
Learn Ajax hereLearn Ajax here
Learn Ajax here
 
Ajax and PHP
Ajax and PHPAjax and PHP
Ajax and PHP
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
ASP.NET WEB API Training
ASP.NET WEB API TrainingASP.NET WEB API Training
ASP.NET WEB API Training
 
Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat Client
 
Ajax presentation
Ajax presentationAjax presentation
Ajax presentation
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSIT
 
Introduction to ajax
Introduction  to  ajaxIntroduction  to  ajax
Introduction to ajax
 
Copy of ajax tutorial
Copy of ajax tutorialCopy of ajax tutorial
Copy of ajax tutorial
 
PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
AJAX - An introduction
AJAX - An introductionAJAX - An introduction
AJAX - An introduction
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
HTML5 - An introduction
HTML5 - An introductionHTML5 - An introduction
HTML5 - An introduction
 
Excellent rest using asp.net web api
Excellent rest using asp.net web apiExcellent rest using asp.net web api
Excellent rest using asp.net web api
 
Tips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC ApplicationsTips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC Applications
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 

Viewers also liked

Synapse india basic php development part 1
Synapse india basic php development part 1Synapse india basic php development part 1
Synapse india basic php development part 1Synapseindiappsdevelopment
 
Synapseindia android apps (operating system)
Synapseindia android apps (operating system)Synapseindia android apps (operating system)
Synapseindia android apps (operating system)Synapseindiappsdevelopment
 
SynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architectureSynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architectureSynapseindiappsdevelopment
 
SynapseIndia dotnet web applications development
SynapseIndia  dotnet web applications developmentSynapseIndia  dotnet web applications development
SynapseIndia dotnet web applications developmentSynapseindiappsdevelopment
 
Synapse india fundamentals of dotnet development
Synapse india fundamentals of dotnet  developmentSynapse india fundamentals of dotnet  development
Synapse india fundamentals of dotnet developmentSynapseindiappsdevelopment
 
Synapse india dotnet development web approch
Synapse india dotnet development web approchSynapse india dotnet development web approch
Synapse india dotnet development web approchSynapseindiappsdevelopment
 
SynapseIndia drupal presentation on drupal info
SynapseIndia drupal  presentation on drupal infoSynapseIndia drupal  presentation on drupal info
SynapseIndia drupal presentation on drupal infoSynapseindiappsdevelopment
 
SynapseIndia dotnet development panel control
SynapseIndia dotnet development panel controlSynapseIndia dotnet development panel control
SynapseIndia dotnet development panel controlSynapseindiappsdevelopment
 
Synapseindia android apps development tutorial
Synapseindia android apps  development tutorialSynapseindia android apps  development tutorial
Synapseindia android apps development tutorialSynapseindiappsdevelopment
 

Viewers also liked (15)

Initializing arrays
Initializing arraysInitializing arrays
Initializing arrays
 
Synapse india basic php development part 1
Synapse india basic php development part 1Synapse india basic php development part 1
Synapse india basic php development part 1
 
SynapseIndia mobile apps
SynapseIndia mobile appsSynapseIndia mobile apps
SynapseIndia mobile apps
 
Synapseindia android apps (operating system)
Synapseindia android apps (operating system)Synapseindia android apps (operating system)
Synapseindia android apps (operating system)
 
SynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architectureSynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architecture
 
SynapseIndia dotnet web applications development
SynapseIndia  dotnet web applications developmentSynapseIndia  dotnet web applications development
SynapseIndia dotnet web applications development
 
Synapse india fundamentals of dotnet development
Synapse india fundamentals of dotnet  developmentSynapse india fundamentals of dotnet  development
Synapse india fundamentals of dotnet development
 
Synapse india mobile apps part1
Synapse india  mobile apps part1Synapse india  mobile apps part1
Synapse india mobile apps part1
 
Synapseindia reviews
Synapseindia reviewsSynapseindia reviews
Synapseindia reviews
 
Synapse india dotnet development web approch
Synapse india dotnet development web approchSynapse india dotnet development web approch
Synapse india dotnet development web approch
 
C compiler-ide
C compiler-ideC compiler-ide
C compiler-ide
 
SynapseIndia drupal presentation on drupal info
SynapseIndia drupal  presentation on drupal infoSynapseIndia drupal  presentation on drupal info
SynapseIndia drupal presentation on drupal info
 
Synapseindia framework for E Commerce
Synapseindia framework for E CommerceSynapseindia framework for E Commerce
Synapseindia framework for E Commerce
 
SynapseIndia dotnet development panel control
SynapseIndia dotnet development panel controlSynapseIndia dotnet development panel control
SynapseIndia dotnet development panel control
 
Synapseindia android apps development tutorial
Synapseindia android apps  development tutorialSynapseindia android apps  development tutorial
Synapseindia android apps development tutorial
 

Similar to Synapseindia dot net development web applications with ajax

Introduction to AJAX
Introduction to AJAXIntroduction to AJAX
Introduction to AJAXAbzetdin Adamov
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.pptWalaSidhom1
 
Ajax tutorial by bally chohan
Ajax tutorial by bally chohanAjax tutorial by bally chohan
Ajax tutorial by bally chohanWebVineet
 
Webservices
WebservicesWebservices
Webservicess4al_com
 
Internet Explorer 8
Internet Explorer 8Internet Explorer 8
Internet Explorer 8David Chou
 
AJAX
AJAXAJAX
AJAXARJUN
 
Unit-5.pptx
Unit-5.pptxUnit-5.pptx
Unit-5.pptxitzkuu01
 
Ajax Introduction
Ajax IntroductionAjax Introduction
Ajax IntroductionOliver Cai
 
Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Asher Martin
 
SynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client librarySynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client librarySynapseindiappsdevelopment
 
Web Server and how we can design app in C#
Web Server and how we can design app  in C#Web Server and how we can design app  in C#
Web Server and how we can design app in C#caohansnnuedu
 
Using Ajax In Domino Web Applications
Using Ajax In Domino Web ApplicationsUsing Ajax In Domino Web Applications
Using Ajax In Domino Web Applicationsdominion
 
WEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptxWEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptxkarthiksmart21
 
Walther Ajax4
Walther Ajax4Walther Ajax4
Walther Ajax4rsnarayanan
 
HTML5/JavaScript Communication APIs - DPC 2014
HTML5/JavaScript Communication APIs - DPC 2014HTML5/JavaScript Communication APIs - DPC 2014
HTML5/JavaScript Communication APIs - DPC 2014Christian Wenz
 

Similar to Synapseindia dot net development web applications with ajax (20)

Ajax
AjaxAjax
Ajax
 
Introduction to AJAX
Introduction to AJAXIntroduction to AJAX
Introduction to AJAX
 
AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
Ajax tutorial by bally chohan
Ajax tutorial by bally chohanAjax tutorial by bally chohan
Ajax tutorial by bally chohan
 
08 ajax
08 ajax08 ajax
08 ajax
 
Webservices
WebservicesWebservices
Webservices
 
Internet Explorer 8
Internet Explorer 8Internet Explorer 8
Internet Explorer 8
 
AJAX
AJAXAJAX
AJAX
 
Unit-5.pptx
Unit-5.pptxUnit-5.pptx
Unit-5.pptx
 
Ajax Introduction
Ajax IntroductionAjax Introduction
Ajax Introduction
 
M Ramya
M RamyaM Ramya
M Ramya
 
Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2
 
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
 
Web Server and how we can design app in C#
Web Server and how we can design app  in C#Web Server and how we can design app  in C#
Web Server and how we can design app in C#
 
Using Ajax In Domino Web Applications
Using Ajax In Domino Web ApplicationsUsing Ajax In Domino Web Applications
Using Ajax In Domino Web Applications
 
WEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptxWEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptx
 
Walther Ajax4
Walther Ajax4Walther Ajax4
Walther Ajax4
 
HTML5/JavaScript Communication APIs - DPC 2014
HTML5/JavaScript Communication APIs - DPC 2014HTML5/JavaScript Communication APIs - DPC 2014
HTML5/JavaScript Communication APIs - DPC 2014
 

More from Synapseindiappsdevelopment

Synapse india elance top in demand in it skills
Synapse india elance top in demand in it skillsSynapse india elance top in demand in it skills
Synapse india elance top in demand in it skillsSynapseindiappsdevelopment
 
SynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseindiappsdevelopment
 
SynapseIndia dotnet module development part 1
SynapseIndia  dotnet module development part 1SynapseIndia  dotnet module development part 1
SynapseIndia dotnet module development part 1Synapseindiappsdevelopment
 
SynapseIndia dotnet development platform overview
SynapseIndia  dotnet development platform overviewSynapseIndia  dotnet development platform overview
SynapseIndia dotnet development platform overviewSynapseindiappsdevelopment
 
SynapseIndia dotnet development framework
SynapseIndia  dotnet development frameworkSynapseIndia  dotnet development framework
SynapseIndia dotnet development frameworkSynapseindiappsdevelopment
 
SynapseIndia dotnet website security development
SynapseIndia  dotnet website security developmentSynapseIndia  dotnet website security development
SynapseIndia dotnet website security developmentSynapseindiappsdevelopment
 
SynapseIndia mobile build apps management
SynapseIndia mobile build apps managementSynapseIndia mobile build apps management
SynapseIndia mobile build apps managementSynapseindiappsdevelopment
 
SynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architectureSynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architectureSynapseindiappsdevelopment
 
SynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseindiappsdevelopment
 
SynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically developmentSynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically developmentSynapseindiappsdevelopment
 
SynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax DevelopmentSynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax DevelopmentSynapseindiappsdevelopment
 
SynapseIndia drupal presentation on drupal best practices
SynapseIndia drupal  presentation on drupal best practicesSynapseIndia drupal  presentation on drupal best practices
SynapseIndia drupal presentation on drupal best practicesSynapseindiappsdevelopment
 
SynapseIndia drupal presentation on drupal
SynapseIndia drupal  presentation on drupalSynapseIndia drupal  presentation on drupal
SynapseIndia drupal presentation on drupalSynapseindiappsdevelopment
 
SynapseIndia dotnet debugging development process
SynapseIndia dotnet debugging development processSynapseIndia dotnet debugging development process
SynapseIndia dotnet debugging development processSynapseindiappsdevelopment
 

More from Synapseindiappsdevelopment (20)

Synapse india elance top in demand in it skills
Synapse india elance top in demand in it skillsSynapse india elance top in demand in it skills
Synapse india elance top in demand in it skills
 
SynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture module
 
SynapseIndia dotnet module development part 1
SynapseIndia  dotnet module development part 1SynapseIndia  dotnet module development part 1
SynapseIndia dotnet module development part 1
 
SynapseIndia dotnet framework library
SynapseIndia  dotnet framework librarySynapseIndia  dotnet framework library
SynapseIndia dotnet framework library
 
SynapseIndia dotnet development platform overview
SynapseIndia  dotnet development platform overviewSynapseIndia  dotnet development platform overview
SynapseIndia dotnet development platform overview
 
SynapseIndia dotnet development framework
SynapseIndia  dotnet development frameworkSynapseIndia  dotnet development framework
SynapseIndia dotnet development framework
 
SynapseIndia dotnet website security development
SynapseIndia  dotnet website security developmentSynapseIndia  dotnet website security development
SynapseIndia dotnet website security development
 
SynapseIndia mobile build apps management
SynapseIndia mobile build apps managementSynapseIndia mobile build apps management
SynapseIndia mobile build apps management
 
SynapseIndia java and .net development
SynapseIndia java and .net developmentSynapseIndia java and .net development
SynapseIndia java and .net development
 
SynapseIndia php web development
SynapseIndia php web developmentSynapseIndia php web development
SynapseIndia php web development
 
SynapseIndia mobile apps architecture
SynapseIndia mobile apps architectureSynapseIndia mobile apps architecture
SynapseIndia mobile apps architecture
 
SynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architectureSynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architecture
 
SynapseIndia dotnet development
SynapseIndia dotnet developmentSynapseIndia dotnet development
SynapseIndia dotnet development
 
SynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseIndia dotnet client library Development
SynapseIndia dotnet client library Development
 
SynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically developmentSynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically development
 
SynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax DevelopmentSynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax Development
 
SynapseIndia mobile apps trends, 2013
SynapseIndia mobile apps  trends, 2013SynapseIndia mobile apps  trends, 2013
SynapseIndia mobile apps trends, 2013
 
SynapseIndia drupal presentation on drupal best practices
SynapseIndia drupal  presentation on drupal best practicesSynapseIndia drupal  presentation on drupal best practices
SynapseIndia drupal presentation on drupal best practices
 
SynapseIndia drupal presentation on drupal
SynapseIndia drupal  presentation on drupalSynapseIndia drupal  presentation on drupal
SynapseIndia drupal presentation on drupal
 
SynapseIndia dotnet debugging development process
SynapseIndia dotnet debugging development processSynapseIndia dotnet debugging development process
SynapseIndia dotnet debugging development process
 

Recently uploaded

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 

Recently uploaded (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 

Synapseindia dot net development web applications with ajax

  • 1. Creating Rich Client Web Applications with AJAX
  • 2. Agenda • Web Apps: Whats good, whats not • What is AJAX and how can AJAX help with the bad? • Creating simple AJAX applications • AJAX endpoints and payloads • Using third-party AJAX libraries • AJAX security • ASP.NET 2.0 client callbacks and Atlas
  • 3. The Good, Bad and Ugly (of Web Applications) Condensed Version • The Good – Centralized control of the application – Easy deployment • The Bad – Locked into the browser sandbox – Loose the “thick-client” experience – One way to get data – the browser postback • The Ugly – Browser compatibility
  • 4. How does AJAX help? • Keep all of the good of thin client • Bring the “thick-client” experience much closer to the thin client • Escape the standard client/server HTTP request communications paradigm (the “postback”)
  • 5. What the heck is AJAX? • Asynchronous JavaScript And XML – No new technologies here, just a new name • Takes advantage of modern uplevel browser features: – A client side XML parser (on Windows this is generally the Microsoft XML parser) • Send data to/receive data from the server outside of the browsers standard communications mechanism (eg the postback) • Parse and enumerate XML formatted data on the client – A rich Document Object Model (DOM) • Powerful interaction points between the different elements of your webpage, the browser and browser plugins
  • 6. The standard web client/server request processing model HTTP/1.1 200 OK Date: Fri, 04 Nov 2005 17:17:37 GMT Server: Microsoft-IIS/6.0 P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI" X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Cache-Control: private Content-Type: text/html; charset=utf-8 Content-Length: 22370 GET / HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* Accept-Language: en-us Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Host: www.microsoft.com Proxy-Connection: Keep-Alive Cookie: MC1=GUID=5cd2d5ca1a1cc54183c10f4bacaa45fa&HASH=cad5&LV=20059&V=3; A=I&I=AxUFAAAAAABuCAAAzJInmvNBZzRHm8aAr99x0A!!; msresearch=1 Browser makes a resource request to the server <html dir="ltr" lang="en"> <head> <META http-equiv="Content-Type" content="text/html; charset=utf-8" > <!--TOOLBAR_EXEMPT--> <meta http-equiv="PICS-Label" content="(PICS-1.1 &quot;http://www.rsac.org/ratingsv01.html&quot; l gen true r (n 0 s 0 v 0 l 0))" > <meta name="KEYWORDS" content="products; headlines; downloads; news; Web site; what's new; solutions; services; software; contests; corporate news;" > <meta name="DESCRIPTION" content="The entry page to Microsoft's Web site. Find software, solutions, answers, support, and Microsoft news." > <meta name="MS.LOCALE" content="EN-US" > <meta name="CATEGORY" content="home page" > <title>Microsoft Corporation</title> <base href="http://g.msn.com/mh_mshp/98765" > <style type="text/css" media="all"> Server processes the request and returns a result to the browser HTTP Request <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > HTTP Response
  • 7. Demo • A simple HTML postback example
  • 8. Problems with this model • To get any data requires complete round trip to the server which is inefficient • UI suffers because the entire UI must be refreshed as part of the postback, even if it does not change (users see the page “flash”) • User is blocked from continuing to work until the page is returned from the postback
  • 9. The client/server request processing model using AJAX GET /AjaxPresentation/AjaxWithHandler/SimpleAjax.ashx?DataRequest=true&val1=2&val2=2 HTTP/1.1 Accept: */* Accept-Language: en-us Referer: http://localhost/AjaxPresentation/AjaxWithHandler/SimpleAjax.aspx Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Host: localhost Proxy-Connection: Keep-Alive Cookie: .ASPXANONYMOUS=AcYSqWXDsOAzMTgxM2IwZi04YzdiLTQyMWMtYjJiNi0yYWVmNDA5OGY0Njg1; ASP.NET_SessionId=rq0avnqjfi5eer45zeq0qdj1 Server processes the request and returns a result to the browser Browser makes a resource request to the server HTTP Request Using XMLHTTP object, an async HTTP request is made to the server JavaScript callback function handles XMLHTTP response HTTP Response HTTP/1.1 200 OK Server: Microsoft-IIS/5.1 Date: Fri, 04 Nov 2005 17:33:53 GMT X-Powered-By: ASP.NET X-AspNet-Version: 1.1.4322 Cache-Control: private Content-Type: text/html; charset=utf-8 Content-Length: 1 4
  • 10. AJAX Advantages • Send an receive only the data you need – Think chatty, not chunky • Only update portions of the page that need to be updated • Asynchronous, so users can continue to work while the page is updated, and more data is fetched
  • 11. Creating Ajax applications • Use JavaScript to instantiate the XML parser //Works in Mozilla (Firefox) and Safari var oXml = new XMLHttpRequest(); Works in Internet Explorer var oXml = new ActiveXObject("Microsoft.XMLHTTP"); • Use the XML object to create a new HTTP request to the server: oXml.Open("GET", “Endpoint.aspx”, true); • Use the XML objects onreadystatechange property to assign a client-side callback method
  • 12. Demo • A simple AJAX demo
  • 13. Side note: Debugging Client Script via Internet Explorer – Enable script debugging – Display script error notifications – Add the “debugger” command to your script • Mozilla supports debugging via Venkman debugger add-in
  • 14. AJAX Endpoints • Anything that can be accessed via HTTP can serve as an AJAX endpoint – Standard ASP.NET webpages (*.aspx) – HTTP Handlers (*.ashx, or custom extenstions) – Web Services (*.asmx) – PHP Web Pages • Think about endpoint performance – ASPX endpoints require a complete page lifecycle to execute on each request – Handlers and Web Services are much more lightweight – Both can access Session, Cache etc
  • 15. Demo • Using Handlers as AJAX endpoints • Accessing Session from an Handler
  • 16. Controlling Asynchronous Communications • Create timer based operations using JavaScripts setInterval command • Make sure you control the number of open HTTP connections, as well as the polling interval
  • 17. Demo • Adding AJAX Asynchronous polling
  • 18. AJAX Payloads • The AJAX “Payload” is the data returned by the HTTP request. • Since Ajax is simply a standard HTTP request/response, the response payload can be anything you like • Examples: – XML, HTML, Simple Types (number, string), JSON • Remember that the actual HTTP payload will always be a type of string, so objects must be serialized
  • 19. Primary Payload Types • Two primary types of payloads in AJAX: – XML • Simple, easy to read format, but you generally must use the MS XML Parser and DOM to work with it • Native to .NET – easy to create on and transport from the server – JSON (JavaScript Object Notation) • Slightly more complex • Data must be massaged into JSON format • Easier to work with once its on the client • Either supports complex object serialization
  • 20. Using XML Payloads • Use the XML DOM to examine and manipulate XML data on the client – ResponseXml property automatically provides a representation of data as parsed by the MSXML XMLDOM parser – XMLDOM provides complete XML navigation concepts: Document, Element, Node – Use client side XSLT to transform or format data – ParseError object tells you if the returned XML was badly formed //Works in Mozilla (Firefox) and Safari var oXsl = new XSLTProcessor(); //Works in Internet Explorer var oXsl = new ActiveXObject("MSXML2.DOMDocument");
  • 21. Demo • Parsing AJAX XML payloads • Using XSLT with AJAX Payloads
  • 22. JSON • JSON (JavaScript Object Notation) is a lightweight data-interchange format. • It is easy for humans to read and write. • It is easy for machines to parse and generate. • Useful as a data-interchange because it can be trivially parsed by JavaScript's built in eval() procedure. var json_data; json_data = ""The quick brown fox.""; myObject = eval("return " + json_data);
  • 23. Examples of JSON • Object serialized to JSON example {"menu": { "id": "file", "value": "File", "popup": { "menuitem": [ {"value": "New", "onclick": "CreateNewDoc()"}, {"value": "Open", "onclick": "OpenDoc()"}, {"value": "Close", "onclick": "CloseDoc()"} ] } }} • The same text expressed as XML: <menu id="file" value="File"> <popup> <menuitem value="New" onclick="CreateNewDoc()" /> <menuitem value="Open" onclick="OpenDoc()" /> <menuitem value="Close" onclick="CloseDoc()" /> </popup> </menu>
  • 24. Other AJAX libraries • Server Side Libraries – Ajax.NET http://ajax.schwarz-interactive.de/csharpsample/default.aspx – PHP & ASP http://cpaint.sourceforge.net/ • Client Side Libraries – Google AJAXSLT http://goog-ajaxslt.sourceforge.net/ – Dojo http://dojotoolkit.org/
  • 25. Ajax.NET • Open Source AJAX implementation for .NET (Note: while still available, the project is not longer being actively developed) • Easy to use. Requires a simple method attribute ( [AjaxMethod()]) to expose server side methods as AJAX endpoints • Automatically uses JSON to transport complex objects like DataSets • Uses dynamically generated JavaScript to create client side proxies for server side objects • Supports transport of integers, strings, doubles, booleans, DateTime, DataSets, DataTables and primitive types of custom classes and arrays • Other types supported via Custom Type converters
  • 26. Demo • Using Ajax.NET
  • 27. AJAX Security • HTTPS is your friend • Keep sensitive code or data on the server where you can control it • By default everything is sent clear text over the wire (including client side code), and could potentially be captured in transit and modified • JavaScript has no intrinsic over-the-wire encryption support, but you can implement your own encryption (search Google for ‘AJAX encryption’)
  • 28. Client Callbacks • New Feature in ASP.NET 2.0 • Add client-side callbacks to your web pages or server controls • Executes in the context of the current page – Allows you to access existing control state on the server during the callback process – Keeps you from having to pass as much data back • Not as flexible in setting endpoints, and passing arguments
  • 29. Atlas • Microsofts next generation AJAX framework – Cross browser compatible • Includes both declarative and imperative programming models – Code in vanilla JavaScript, or use the Atlas “tag” programming model • Attempts to bring JavaScript to a first class language – Uses abstraction layers to add familiar programming constructs like Types, Enumerations, Class Inheritance – Also uses abstraction layers to abstract cross browser problems • Includes a number of controls for common functionality
  • 30. Declarative Atlas <page xmlns:script="http://schemas.microsoft.com/xml-script/2005" xmlns:wiki="wiki"> <components> <label targetElement="loadingMsg1"> <bindings> <binding dataContext="documentsSource1" dataPath="isReady" property="visible" transform="Invert"/> </bindings> </label> <textBox targetElement="<%= navCategoryID.ClientID %>" /> <textBox targetElement="<%= navDefaultDocumentTitle.ClientID %>"/> <textBox targetElement="recurseSubfolders1"/> <dataSource id="documentsSource1" serviceURL="<%= ResolveUrl("~/WebServices/DocumentWebService.asmx") %>"> <bindings> <binding dataContext="<%= navCategoryID.ClientID %>" dataPath="text" property="selectParameters" propertyKey="categoryID"/> <binding dataContext="<%= navDefaultDocumentTitle.ClientID %>" dataPath="text" property="selectParameters“ propertyKey="defaultDocumentTitle"/> <binding dataContext="recurseSubfolders1" dataPath="text" property="selectParameters" propertyKey="strRecurseSubfolders"/> </bindings> </dataSource>