AJAX stands for Asynchronous JavaScript And XML. AJAX is not a new programming technology but a concept which makes use of existing technologies. AJAX is based on JavaScript, XML and HTTP requests.
AJAX is a browser based client side scripting technology.
AJAX allows to refresh smaller portion of a webpage without reloading the entire webpage. This makes an AJAX application faster and more interactive.
AJAX uses asynchronous data transfer (HTTP requests) between the browser and the web server, allowing web pages to request small bits of information from the server instead of whole pages.
AJAX uses XMLHttpRequest object of Javascript to communicate asynchronously with webserver.
Javascript,XML,HTML and CSS.
No. All components of AJAX are established based on web standards which are mostly supported by all browsers.
With AJAX, you can use both GET and POST methods. It is an argument to the open method.
open() and send() methods are used to send data to a web server.
open() method takes 3 arguments:
First argument specifies GET or POST method.
Second argument sepcifies the url to be invoked.
Third argument specifies if the request is asynchronous are not.
send() method sends the request to the server.
AJAX requests should use an HTTP GET request when retrieving data where the data will not change for a given request URL. An HTTP POST should be used when state is updated on the server. This is in line with HTTP idempotency recommendations and is highly recommended for a consistent web application architecture.
AJAX is basically an asyncronous processing concept. A synchronous request would block in page event processing and there are not many cases where a synchronous request is required.
onreadystatechange event listening property of XMLHttpRequest which is mapped to a user defined function. The mapped function will be automatically processed after the server response event.
The readyState is a read only property which holds the status of the server's response. Each time the readyState changes, the onreadystatechange function will be executed.
The following are the possible values for the readyState property:
0 - The request is not initialized
1 - The request has been set up
2 - The request has been sent
3 - The request is in process
4 - The request is complete
The responseText property holds the text returned from the web server for the specific request.
While responseText returns the HTTP response as a string, responseXML returns the response as XML. The responseXML property returns an XML document object, which can be examined and parsed.
Call the abort() method on the request object.
You can make more than one simultaneous AJAX request. The response may not in the same order as request sequence. Internet Explorer allows only two requests at a time, others browsers may allow upto 5 simultaneous requests.
AJAX is mostly driven by Javascript and Javascript is loosely built based on Java conventions. JavaScript can not access the local filesystem without the user's permission. An AJAX interaction can only be made with the servers-side component from which the page was loaded, etc makes AJAX pretty safe.
The prominant AJAX frameworks (actually Javascript libraries) are DWR, Dojo toolkit, Prototype, GWT and Yahoo UI.
DWR stands for Direct Web Reporting. DWR allows Javascript in a browser to interact with Java on a server and helps you manipulate web pages with the results. On the server side DWR uses a Servlet to interact with the Java objects and returns object representations of the Java objects or XML documents. DWR is also sometimes referred as Reverse-Ajax.
The following are the features of Dojo Toolkit:
- Powerful AJAX-based I/O abstraction (remoting).
- Graceful degradation.
- Backward, forward, bookmarking support.
- Aspect-oriented event system.
- Markup-based UI construction through widgets.
- Widget prototyping.
- Animation
Prototype JavaScript library contains a set of JavaScript objects for representing AJAX requests and contains utility functions for accessing in page components and DOM manipulations.
With Google Web Toolkit (GWT), you write your AJAX front-end in the Java programming language which GWT then cross-compiles into optimized JavaScript that automatically works across all major browsers.
The Yahoo User Interface (YUI) Library is a set of utilities and controls, written in JavaScript, for building richly interactive web applications using techniques such as DOM scripting, DHTML and AJAX. The YUI Library also includes several core CSS resources