This work is licensed under a Creative Commons |
Asynchronous JavaScript and XML (AJAX) is a technology which allows client-side JavaScript to make requests to a server without causing a reload of the current page in the browser. Using AJAX and standard DOM methods, client-side JavaScript can request, receive, and visualize information in the context of a single Web page. The advantage of AJAX over more traditional Web pages is that they better resemble the behavior of desktop applications, providing enhanced features and usability for the user.
XMLHttpRequest
API allows client/server-interactionXMLHttpRequest
[2]locally
XMLHttpRequest
[2]state changesis not easy
savecould represent the state with a URI (round-trip required)
Link to this pagebutton for URI creation
http://maps.google.com/?ll=37.84,-122.28&spn=0.10,0.16&t=h&layer=t
XMLHttpRequest
[2]Method | Description |
---|---|
abort()
|
Cancels the current request. |
getAllResponseHeaders()
|
Returns the complete set of HTTP headers as a string. |
getResponseHeader(headerName)
|
Returns the value of the specified HTTP header. |
open(method, URL)
open(method, URL, async)
open(method, URL, async, userName)
open(method, URL, async, userName, password)
|
Specifies the method, URL, and other optional attributes of a request. The URL parameter may be either a relative or complete URL. The asyncparameter specifies whether the request should be handled asynchronously or not – truemeans that script processing carries on after the send() method, without waiting for a response, and falsemeans that the script waits for a response before continuing script processing. |
send(content)
|
Sends the request. |
setRequestHeader(label, value)
|
Adds a label/value pair to the HTTP header to be sent. |
XMLHttpRequest
[2]XMLHttpRequest
API has been built for requesting XML via HTTPeval()
functioneval()
works fast and requires no programming<?xml version="1.0"?> <menu id="file" value="File"> <popup> <menuitem value="New" onclick="CreateNewDoc()"/> <menuitem value="Open" onclick="OpenDoc()"/> <menuitem value="Close" onclick="CloseDoc()"/> </popup> </menu>
{ "menu" : { "id" : "file", "value" : "File", "popup" : { "menuitem" : [ { "value" : "New", "onclick" : "CreateNewDoc()" }, { "value" : "Open", "onclick" : "OpenDoc()" }, { "value" : "Close", "onclick" : "CloseDoc()" } ] } }}
XMLHttpRequest
[2]