The Document Object Model is a platform- and programming language-independent standard object model for representing HTML or XML documents as well as an Application Programming Interface for querying, traversing and manipulating such documents.... API
Application programming interface
An application programming interface is a set of subroutine, data structures, class and/or Protocol provided by library and/or operating system Service s in order to support the building of applications.... that can be used inside a web browser
Web browser
A Web browser is a application software which enables a user to display and interact with text, images, videos, music, games and other information typically located on a Web page at a website on the World Wide Web or a local area network.... scripting language
Scripting language
A scripting language, script language or extension language, is a programming language that allows some control of a single or many Application software.... , such as Javascript
JavaScript
JavaScript is a scripting language widely used for client-side web development. It was the originating Programming language dialect of the ECMAScript standard.... , to send an HTTP request
Hypertext Transfer Protocol
Hypertext Transfer Protocol is an application-level protocol for distributed, collaborative, hypermedia information systems. Its use for retrieving inter-linked resources led to the establishment of the World Wide Web.... directly to a web server
Web server
The term web server can mean one of two things:# A computer program that is responsible for accepting Hypertext Transfer Protocol requests from clients , and Server them HTTP responses along with optional data contents, which usually are web pages such as Hypertext Markup Language documents and linked objects .... and load the server response
Response
A response is the following:* Often a response is the result of a stimulus.* In data transmission, a response is the content of the control field of a response frame advising the primary station concerning the processing by the secondary station of one or more command frames.... data directly back into the scripting language. Once the data is within the scripting language, it is available as both an XML document, if the response was valid XML markup, and as plain text
Plain text
In computing, plain text is a term used for an ordinary "unformatted" sequential file readable as textual material without much processing.The Character encoding has traditionally been either ASCII, one of its many derivatives such as ISO/IEC 646 etc., or sometimes EBCDIC.... . The XML data can easily be used to manipulate the currently active document in the browser without the need of the client loading a new web page
Web page
A web page or webpage is a resource of information that is suitable for the World Wide Web and can be accessed through a web browser.This information is usually in HyperText Markup Language or eXtensible HyperText Markup Language format, and may provide Navigation bar to other web pages via hypertext Hyperlink.... document.
The Document Object Model is a platform- and programming language-independent standard object model for representing HTML or XML documents as well as an Application Programming Interface for querying, traversing and manipulating such documents.... API
Application programming interface
An application programming interface is a set of subroutine, data structures, class and/or Protocol provided by library and/or operating system Service s in order to support the building of applications.... that can be used inside a web browser
Web browser
A Web browser is a application software which enables a user to display and interact with text, images, videos, music, games and other information typically located on a Web page at a website on the World Wide Web or a local area network.... scripting language
Scripting language
A scripting language, script language or extension language, is a programming language that allows some control of a single or many Application software.... , such as Javascript
JavaScript
JavaScript is a scripting language widely used for client-side web development. It was the originating Programming language dialect of the ECMAScript standard.... , to send an HTTP request
Hypertext Transfer Protocol
Hypertext Transfer Protocol is an application-level protocol for distributed, collaborative, hypermedia information systems. Its use for retrieving inter-linked resources led to the establishment of the World Wide Web.... directly to a web server
Web server
The term web server can mean one of two things:# A computer program that is responsible for accepting Hypertext Transfer Protocol requests from clients , and Server them HTTP responses along with optional data contents, which usually are web pages such as Hypertext Markup Language documents and linked objects .... and load the server response
Response
A response is the following:* Often a response is the result of a stimulus.* In data transmission, a response is the content of the control field of a response frame advising the primary station concerning the processing by the secondary station of one or more command frames.... data directly back into the scripting language. Once the data is within the scripting language, it is available as both an XML document, if the response was valid XML markup, and as plain text
Plain text
In computing, plain text is a term used for an ordinary "unformatted" sequential file readable as textual material without much processing.The Character encoding has traditionally been either ASCII, one of its many derivatives such as ISO/IEC 646 etc., or sometimes EBCDIC.... . The XML data can easily be used to manipulate the currently active document in the browser without the need of the client loading a new web page
Web page
A web page or webpage is a resource of information that is suitable for the World Wide Web and can be accessed through a web browser.This information is usually in HyperText Markup Language or eXtensible HyperText Markup Language format, and may provide Navigation bar to other web pages via hypertext Hyperlink.... document. Plain text data can be evaluated
Interpreter (computing)
In computer science, an interpreter normally means a computer program that execution , i.e. performs, instructions written in a programming language.... within the scripting language to manipulate the document, too; in the example of Javascript, the plain text may be formatted as JSON
JSON
JSON , short for JavaScript Object Notation, is a lightweight computer data interchange format. It is a text-based, human-readable format for representing simple data structures and associative arrays .... by the web server and evaluated within Javascript to create an object
Object (computer science)
In its simplest embodiment, an object is an allocated region of storage. Since programming languages use variable#Computer_programmings to access objects, the terms object and variable are often used interchangeably.... of data for use on the current DOM.
Ajax, or AJAX , is a group of interrelated web development techniques used to create interactive web applications or rich Internet applications.... architecture should not be confused with (XDR) XDomainRequest which is a lightweight form of the XMLHttpRequest design by Microsoft which doesn't utilize XML-RPC
XML-RPC
XML-RPC is a remote procedure call protocol which uses XML to encode its calls and [] as a transport mechanism. ... .
Ajax, or AJAX , is a group of interrelated web development techniques used to create interactive web applications or rich Internet applications.... web development technique, and it is used by many websites to implement responsive and dynamic web application
Web application
In software engineering, a web application or webapp is an Application software that is accessed via web browser over a network such as the Internet or an intranet.... s. Examples of web applications that make use of XMLHttpRequest include Google Maps
Google Maps
Google Maps is a free web mapping service application and technology provided by Google that powers many map-based services including the Google Maps website, #Google Ride Finder, Google Transit and embedded maps on third-party websites via the Google Maps Application programming interface.... , Windows Live's Virtual Earth
Virtual earth
Virtual earth may refer to:* Virtual ground - the node of an electrical circuit that is maintained at a steady reference potential, without being connected directly to the reference potential.... , the MapQuest
MapQuest
MapQuest is a map publisher and a free online Web mapping service owned by AOL. The company was founded in 1967 as Cartographic Services, a division of R.R.... dynamic map interface, Facebook
Facebook
Facebook is a free-access social network service website that is operated and privately held company by Facebook, Inc. Users can join networks organized by city, workplace, school, and region to connect and interact with other people.... , and many others.
History and support
The XMLHttpRequest concept was originally developed by Microsoft
Microsoft
Microsoft Corporation is a multinational corporation computer technology corporation that develops, manufactures, licenses, and supports a wide range of computer software products for computing devices.... as a server side API call for Outlook Web Access
Outlook Web Access
Outlook Web Access originally called Exchange Web Connect , is a webmail service of Microsoft Exchange Server 5.0 and later. The web interface of Outlook Web Access resembles the interface in Microsoft Outlook.... 2000 . At the time, it was not a standards-based web client feature; however, de facto support for it has been implemented by many major web browsers. The Microsoft implementation is called XMLHTTP. It has been available since the introduction of Internet Explorer 5.0 and is accessible via JScript
JScript
JScript is the Microsoft dialect of the ECMAScript scripting language specification.JavaScript , JScript, and ECMAScript are very similar languages.... , VBScript
VBScript
VBScript is an Active Scripting language, developed by Microsoft, which uses the Component Object Model to access elements of the environment within which it's running .... and other scripting languages supported by IE browsers. In JScript, Internet Explorer versions prior to 7.0 require XMLHTTP to be invoked as an ActiveXObject, so they cannot instantiate the XMLHttpRequest class without help as follows:
// Provide the XMLHttpRequest class for IE 5.x-6.x:
if( typeof XMLHttpRequest
"undefined" ) XMLHttpRequest = function ;
The Mozilla project incorporated the first compatible native implementation of XMLHttpRequest in Mozilla
Mozilla Application Suite
The Mozilla Application Suite is a cross-platform integrated Internet suite. Its development was initiated by Netscape Communications Corporation, before their acquisition by AOL.... 1.0 in 2002. This implementation was later followed by Apple
Apple Computer
Apple Inc., formerly Apple Computer Inc., is an United States multinational corporation which designs and manufactures consumer electronics and software products.... since Safari
Safari (web browser)
Safari is a web browser developed by Apple Inc.. First released as a beta on January 7, 2003 on the company's Mac OS X operating system, it became Apple's default browser beginning with Mac OS X v10.3, commonly known as "OS X Panther." Apple has also made Safari the native browser for the iPhone OS.... 1.2, Konqueror
Konqueror
Konqueror is a web browser, file manager and file viewer designed as a core part of the KDE. It is developed by volunteers and can run on most Unix-like operating systems.... , Opera Software
Opera Software
Opera Software is a Norwegian corporation, primarily known for its Opera family of web browsers. Opera Software is also involved in promoting Web standards through participation in the World Wide Web Consortium.... since Opera
Opera (web browser)
Opera is a web browser and Internet suite developed by the Opera Software company. Opera handles common Internet-related tasks such as displaying web sites, sending and receiving e-mail messages, managing contacts, IRC online chatting, downloading files via BitTorrent , and reading web feeds.... 8.0, iCab
ICab
iCab is a web browser for the Macintosh by Alexander Clauss, derived from Crystal Atari Browser for Atari TOS compatible computers. It is the only browser being developed for Mac OS 9 and earlier, and is the only one available for Motorola 68000 family-based Macintoshes that features tabbed browsing.... since 3.0b352, and Microsoft since Internet Explorer 7.0.
The World Wide Web Consortium is the main international standards organization for the World Wide Web . It is arranged as a consortium where member organizations maintain full-time staff for the purpose of working together in the development of standards for the World Wide Web.... published a Working Draft specification for the XMLHttpRequest object's API on 15 April 2008. Its goal is "to document a minimum set of interoperable features based on existing implementations, allowing Web developers to use these features without platform-specific code". The draft specification is based upon existing popular implementations, to help improve and ensure interoperability of code across web platforms. As of April 2008, the W3C standard was still a work in progress.
The World Wide Web Consortium is the main international standards organization for the World Wide Web . It is arranged as a consortium where member organizations maintain full-time staff for the purpose of working together in the development of standards for the World Wide Web.... published a Working Draft of XMLHttpRequest2 object's API with some extended functionality (such as progress events, cross-site requests, handling of byte streams).
Web pages that use XMLHttpRequest or XMLHTTP can mitigate the current minor differences in the implementations either by encapsulating the XMLHttpRequest object in a JavaScript
JavaScript
JavaScript is a scripting language widely used for client-side web development. It was the originating Programming language dialect of the ECMAScript standard.... wrapper, or by using an existing framework that does so. In either case, the wrapper should detect the abilities of current implementation and work within its requirements.
Traditionally, there have been other methods to achieve a similar effect of server dynamic applications using scripting language
Scripting language
A scripting language, script language or extension language, is a programming language that allows some control of a single or many Application software.... s and/or plugin
Plugin
In computing, a plug-in consists of a computer program that interacts with a host application software to provide a certain, usually very specific, function "on demand".... s:
IFrame is an HTML element which makes it possible to embed an HTML document inside another HTML document.The size of the IFrame can be specified in the surrounding HTML page, so that the surrounding page can already be presented in the Web browser while the IFrame is still being loaded.... s (or Netscape Navigator
Netscape Navigator
Netscape Navigator and Netscape are the names for the proprietary software web browser popular in the 1990s, and the flagship product of the Netscape Communications Corporation, and the dominant web browser in terms of Usage share of web browsers.... 's equivalent ilayers)
Remote Scripting is a technology which allows scripts running inside a browser to exchange information with a server. The local scripts can invoke scripts on the remote side and process the returned information....
LiveConnect is a feature of Web browsers that allows Java and JavaScript software to intercommunicate within a Web page. From the Java side it allows an applet to invoke the embedded scripts of a page or to access the built-in JavaScript environment, much as scripts can....
ActiveX is a component Object Model developed by Microsoft for Microsoft Windows. By using the Component Object Model runtime, developers can create Component-based software engineering that perform a particular function or a set of functions....
The Adobe Flash Player is software for creating and viewing animations and movies using computer programs such as a web browser; in common usage, flash lets you put animation and movies on a web site....
A Java applet is an applet delivered to the users in the form of Java bytecode. Java applets can run in a Web browser using a Java Virtual Machine , or in Sun Microsystems's AppletViewer, a stand-alone tool for testing applets.... s
In addition, the World Wide Web Consortium has several recommendations that also allow for dynamic communication between a server and user agent, though few of them are well supported. These include:
In computing, an HTML element indicates structure in an HTML document and a way of hierarchically arranging content. More specifically, an HTML element is an Standard Generalized Markup Language element that meets the requirements of one or more of the HTML Document Type Definitions .... defined in HTML 4 for embedding arbitrary content types into documents, (replaces inline frames under XHTML 1.1)
The Document Object Model (DOM) Level 3 Load and Save Specification.
Cross-site HTTP requests
Modern browsers are in the process of implementing cross-site XMLHttpRequests, notably Firefox 3.1.
Known problems
Caching
Most of the implementations also realize HTTP caching. Internet Explorer and Firefox do, but there is a difference in how and when the cached data is revalidated.
Firefox revalidates the cached response every time the page is refreshed, issuing an "If-Modified-Since" header with value set to the value of the "Last-Modified" header of the cached response.
Internet Explorer does so only if the cached response is expired (i.e., after the date of received "Expires" header). This raises some issues, since a bug exists in Internet Explorer, where the cached response is never refreshed.
It is possible to unify the caching behavior on the client. The following script illustrates an example approach (See the history and support section for compatibility with versions of Internet Explorer prior to 7.0):
var request = new XMLHttpRequest;
request.open("GET", url, false);
request.send(null);
if(!request.getResponseHeader("Date"))
In Internet Explorer, if the response is returned from the cache without revalidation, the "Date" header is an empty string. The workaround is achieved by checking the "Date" response header and issuing another request if needed. In case a second request is needed, the actual HTTP request is not made twice, as the first call would not produce an actual HTTP request.
The reference to the cached request is preserved, because if the response code/status of the second call is "304 Not Modified", the response body becomes an empty string ("") and then it is needed to go back to the cached object. A way to save memory and expenses of second object creation is to preserve just the needed response data and reuse the XMLHttpRequest object.
The above script relies on the assumption that the "Date" header is always issued by the server, which should be true for most server configurations. Also, it illustrates a synchronous communication between the server and the client. In case of asynchronous communication, the check should be made during the callback.
This problem is often overcome by employing techniques preventing the caching at all. Using these techniques indiscriminately can result in poor performance and waste of network bandwidth.
If script executes operation that has side effects (e.g. adding a comment, marking message as read) which requires that request always reaches the end server, it should use POST method instead.
Workaround
Internet Explorer will also cache dynamic pages and this is a problem because the URL of the page may not change but the content will (for example a news feed). A workaround for this situation can be achieved by adding a unique time stamp or random number, or possibly both, typically using the Date object and/or Math.random.
For simple document request the query string delimiter '?' can be used, or for existing queries a final sub-query can be added after a final '&' – to append the unique query term to the existing query. The downside is that each such request will fill up the cache with useless (never reused) content that could otherwise be used for other cached content (more useful data will be purged from cache to make room for these one-time responses).
A better workaround can be achieved by adding meta tags to dynamic pages in order to make them no-cachable:
Reusing XMLHttpRequest Object in IE
In IE, if the open method is called after setting the onreadystatechange callback, there will be a problem when trying to reuse the XHR object. To be able to reuse the XHR object properly, use the open method first and set onreadystatechange later. This happens because IE resets the object implicitly in the open method if the status is 'completed'. For more explanation of reuse: . The downside to calling the open method after setting the callback is a loss of cross-browser support for readystates. See
Cross-browser support
Microsoft developers were the first to include the XMLHttp object in their MSXML
MSXML
Microsoft XML Core Services is a set of services that allow applications written in JScript, VBScript, and Microsoft development tools to build Windows-native XML-based applications.... ActiveX
ActiveX
ActiveX is a component Object Model developed by Microsoft for Microsoft Windows. By using the Component Object Model runtime, developers can create Component-based software engineering that perform a particular function or a set of functions.... control. Developers at the open source Mozilla project saw this invention and ported their own XMLHttp, not as an ActiveX control but as a native browser object called XMLHttpRequest. Konqueror
Konqueror
Konqueror is a web browser, file manager and file viewer designed as a core part of the KDE. It is developed by volunteers and can run on most Unix-like operating systems.... , Opera
Opera (web browser)
Opera is a web browser and Internet suite developed by the Opera Software company. Opera handles common Internet-related tasks such as displaying web sites, sending and receiving e-mail messages, managing contacts, IRC online chatting, downloading files via BitTorrent , and reading web feeds.... and Safari
Safari (web browser)
Safari is a web browser developed by Apple Inc.. First released as a beta on January 7, 2003 on the company's Mac OS X operating system, it became Apple's default browser beginning with Mac OS X v10.3, commonly known as "OS X Panther." Apple has also made Safari the native browser for the iPhone OS.... have since implemented similar functionality but more along the lines of an identical XMLHttpRequest. Some Ajax developer and run-time frameworks
Ajax framework
An Ajax framework is a Web application framework that helps to develop web applications that use Ajax , a collection of technologies used to build dynamic web pages on the client side.... only support one implementation of XMLHttp while others support both. Developers building Ajax functionality from scratch can provide if/else logic within their client-side JavaScript to use the appropriate XMLHttp object as well. Internet Explorer 7 added native support for the XMLHttpRequest object, but retains backward compatibility
Backward compatibility
In technology, for example in telecommunications and computing, a device or technology is said to be backwards compatible if it allows input generated by older devices.... with the ActiveX implementation. To avoid excess conditionals, see the source code in the history and support section.
Frameworks
Because of the complexity of handling cross-browser distinctions between XMLHttpRequest implementations, a number of Ajax framework
Ajax framework
An Ajax framework is a Web application framework that helps to develop web applications that use Ajax , a collection of technologies used to build dynamic web pages on the client side.... s have emerged to abstract these differences into a set of reusable programming constructs.
Representational state transfer is a style of software architecture for distributed hypermedia systems such as the World Wide Web. As such, it is not strictly a method for building "web services." The terms "representational state transfer" and "REST" were introduced in 2000 in the doctoral dissertation of Roy Fielding, one of the principa...
The World Wide Web Consortium is the main international standards organization for the World Wide Web . It is arranged as a consortium where member organizations maintain full-time staff for the purpose of working together in the development of standards for the World Wide Web.... Working Draft
A black hat is the villain or bad guy, especially in a Western in which such a character would wear a black hat in contrast to the hero white hat.... security conference. Discusses several issues involving XHR and the future of cross-domain AJAX.