In the 1990s, most websites were based on complete HTML pages. Each user action required a complete page be loaded from the server. This process was inefficient, as reflected by the user experience: all page content disappeared, then reappeared. Each time the browser reloaded a page because of a partial change, all of the content had to be re-sent, even though only some of the information had changed. This placed additional load on the server and used excessive bandwidth. Later in the mid- to late '90s, Microsoft began updating its Internet Explorer browser to better handle content asynchronously, including the introduction of the
On April 5, 2006, the World Wide Web Consortium (W3C) released the first draft specification for the Ajax XMLHttpRequest object in an attempt to create an official Web standard. The standard was created, and as of August 2014 it is still maintained by the W3C.
The term "Ajax" has come to represent a broad group of Web technologies that can be used to implement a Web application that communicates with a server in the background, without interfering with the current state of the page. In the article that coined the term "Ajax," Jesse James Garrett explained the incorporated technologies:
- HTML (or XHTML) and CSS for presentation
- The Document Object Model (DOM) for dynamic display of and interaction with data
- XML for the interchange of data, and XSLT for its manipulation
- The XMLHttpRequest object for asynchronous communication
Some web developers have identified drawbacks to using Ajax, past and present. Examples include:
- In pre-HTML5 browsers, pages dynamically created using successive Ajax requests did not automatically register themselves with the browser's history engine, so clicking the browser's "back" button may not have returned the browser to an earlier state of the Ajax-enabled page. Instead, it may have returned to the last full page visited before it. Such behavior — navigating between pages instead of navigating between page states — may be desirable, but if fine-grained tracking of page state is required, then a pre-HTML5 workaround used invisible iframes to trigger changes in the browser's history. A workaround implemented by Ajax techniques is to change the URL fragment identifier (the part of a URL after the "#") when an Ajax-enabled page is accessed and monitor it for changes. HTML provides an extensive API standard for working with the browser's history engine.
- Dynamic Web page updates also make it difficult to bookmark and return to a particular state of the application. Solutions to this problem exist, many of which again use the URL fragment identifier. The solution provided by HTML5 for the above problem also applies for this.
- Depending on the nature of the Ajax application, dynamic page updates may interfere disruptively with user interactions, especially if working on an unstable Internet connection. For instance, editing a search field may trigger a query to the server for search completions, but the user may not know that a search completion pop-up is forthcoming. If the Internet connection is slow, the pop-up list may show up at an inconvenient time, when the user has already proceeded to do something else.
- Similarly, some Web applications that use Ajax are built in a way that cannot be read by screen-reading technologies, such as JAWS. The WAI-ARIA standards provide a way to provide hints in such a case.
- Screen readers that are able to use Ajax may still not be able to properly read the dynamically generated content.
- The same-origin policy prevents some Ajax techniques from being used across domains, although the W3C has a draft of the XMLHttpRequest object that would enable this functionality. Methods exist to sidestep this security feature by using a special Cross Domain Communications channel embedded as an iframe within a page or by the use of JSONP.
- The asynchronous callback-style of programming required can lead to complex code that is hard to maintain, to debug, and to test. If your page uses a lot of Ajax on load, then WebDriver may not know when it has completely loaded. If you need to ensure such pages are fully loaded, then you can use explicit and implicit waits.
- Ajax Tutorial with GET, POST, text and XML examples.
Numerous elements of this article are reused from the Wikipedia article.
- Ullman, Chris (March 2007). Beginning Ajax. Wrox. ISBN 9780470106754. Archived from the original on 05 July 2008. https://web.archive.org/web/20080705101852/http://www.wrox.com/WileyCDA/Section/id-303217.html. Retrieved 18 August 2014.
- "Dynamic HTML and XML: The XMLHttpRequest Object". Apple Inc. 24 June 2014. Archived from the original on 05 March 2011. https://web.archive.org/web/20110305043442/http://developer.apple.com/internet/webcontent/xmlhttpreq.html. Retrieved 18 August 2014.
- Microsoft Exchange Team (21 June 2005). "Outlook Web Access - A catalyst for web evolution". Microsoft. http://blogs.technet.com/b/exchange/archive/2005/06/21/406646.aspx. Retrieved 18 August 2014.
- Swartz, Aaron (22 December 2005). "A Brief History of Ajax". Raw Thought. http://www.aaronsw.com/weblog/ajaxhistory. Retrieved 18 August 2014.
- Garrett, Jesse James (18 February 2005). "Ajax: A New Approach to Web Applications". Adaptive Path. Archived from the original on 02 July 2008. https://web.archive.org/web/20080702075113/http://www.adaptivepath.com/ideas/essays/archives/000385.php. Retrieved 18 August 2014.
- English, Paul (12 April 2006). "Kayak User Interface". Official Kayak.com Technoblog. Kayak.com. http://kayaklabs.blogspot.com/2006/04/kayak-user-interface.html. Retrieved 18 August 2014.
- "The XMLHttpRequest Object". World Wide Web Consortium. 5 April 2006. Archived from the original on 16 May 2008. https://web.archive.org/web/20080516060525/http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060405/. Retrieved 18 August 2014.
- "XMLHttpRequest Living Standard". W3C. 12 August 2014. http://xhr.spec.whatwg.org/. Retrieved 18 August 2014.
- Lacava, Alessandro (5 October 2006). "Speed Up Your Ajax-based Apps with JSON". DevX.com. Jupitermedia Corporation. Archived from the original on 04 July 2008. https://web.archive.org/web/20080704134131/http://www.devx.com/Webdev/Article/32651. Retrieved 18 August 2014.
- "Why use AJAX?". InterAKT. 10 November 2005. Archived from the original on 29 May 2008. https://web.archive.org/web/20080529080808/http://www.interaktonline.com/support/articles/Details/AJAX:+Asynchronously+Moving+Forward-Why+use+AJAX%3F.html?id_art=36&id_asc=309. Retrieved 26 June 2008.
- Li, Andy (8 April 2009). "Deep Linking for AJAX". Andy Li's Blog. http://blog.onthewings.net/2009/04/08/deep-linking-for-ajax/. Retrieved 18 August 2014.
- "7.5 Session history and navigation". HTML Specification. WHATWG. 6 August 2014. http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#history. Retrieved 18 October 2014.
- Prokoph, Andreas (8 May 2007). "Help Web crawlers efficiently crawl your portal sites and Web sites". developerWorks. IBM. http://www.ibm.com/developerworks/library/x-sitemaps/index.html. Retrieved 18 August 2014.
- Quinsey, Peter (5 December 2006). "User-Proofing Ajax". A List Apart. http://www.alistapart.com/articles/userproofingajax. Retrieved 18 August 2014.
- Henry, Shawn Lawton (September 2010). "WAI-ARIA Overview". W3C. Archived from the original on 26 October 2010. https://web.archive.org/web/20101026062837/http://www.w3.org/WAI/intro/aria.php. Retrieved 18 August 2014.
- Edwards, James (5 May 2006). "Ajax and Screenreaders: When Can it Work?". SitePoint. http://www.sitepoint.com/ajax-screenreaders-work/. Retrieved 18 August 2014.
- "Cross-Origin Resource Sharing". W3C. 11 June 2012. https://dvcs.w3.org/hg/cors/raw-file/tip/Overview.html. Retrieved 18 August 2014.
- Thorpe, Danny (July 2007). "Secure Cross-Domain Communication in the Browser". The Architecture Journal. Microsoft. http://msdn.microsoft.com/en-us/library/bb735305.aspx. Retrieved 18 August 2014.
- "Selenium-WebDriver API Commands and Operations". Selenium WebDriver. Selenium Project. 31 July 2014. http://seleniumhq.org/docs/03_webdriver.html#fetching-a-page. Retrieved 18 August 2014.
- "WebDriver: Advanced Usage". Selenium WebDriver. Selenium Project. 31 July 2014. http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp. Retrieved 18 August 2014.