Difference between revisions of "Ajax (programming)"

From LIMSWiki
Jump to navigationJump to search
(Creating stub record. Saving and modifying more of its content.)
 
m (Internal links)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''Ajax''' (also '''AJAX''') is a group of interrelated Web development techniques used on the client-side to create asynchronous Web applications. With Ajax, Web applications can send data to and retrieve data from a server asynchronously (in the background) without interfering with the display and behavior of the existing page. Data can be retrieved using the XMLHttpRequest object and API (application programming interface). Despite the name, the use of XML is not required; JavaScript Object Notation (JSON) is often used instead, and the requests do not need to be asynchronous.<ref name="UllmanWrox">{{cite book
'''Ajax''' (also '''AJAX''') is a group of interrelated Web development techniques used on the client-side to create asynchronous Web applications. With Ajax, Web applications can send data to and retrieve data from a server asynchronously (in the background) without interfering with the display and behavior of the existing page. Data can be retrieved using the XMLHttpRequest object and API (application programming interface). Despite the name, the use of [[XML]] is not required; [[JSON|JavaScript Object Notation]] (JSON) is often used instead, and the requests do not need to be asynchronous.<ref name="UllmanWrox">{{cite book
|url=http://www.wrox.com/WileyCDA/Section/id-303217.html |archiveurl=https://web.archive.org/web/20080705101852/http://www.wrox.com/WileyCDA/Section/id-303217.html |title=Beginning Ajax |author=Ullman, Chris |publisher=Wrox |date=March 2007 |isbn=9780470106754 |archivedate=05 July 2008 |accessdate=18 August 2014}}</ref>
|url=http://www.wrox.com/WileyCDA/Section/id-303217.html |archiveurl=https://web.archive.org/web/20080705101852/http://www.wrox.com/WileyCDA/Section/id-303217.html |title=Beginning Ajax |author=Ullman, Chris |publisher=Wrox |date=March 2007 |isbn=9780470106754 |archivedate=05 July 2008 |accessdate=18 August 2014}}</ref>


Line 10: Line 10:


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.<ref name="XHRStand">{{cite web
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.<ref name="XHRStand">{{cite web
|url=http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060405/ |archiveurl=https://web.archive.org/web/20080516060525/http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060405/ |title=The XMLHttpRequest Object |publisher=World Wide Web Consortium |date=05 April 2006 |archivedate=16 May 2008 |accessdate=18 August 2014}}</ref> The standard was created, and as of August 2014 is still maintained by the W3C.<ref name="XHRLivingStand">{{cite web |url=http://xhr.spec.whatwg.org/ |title=XMLHttpRequest Living Standard |publisher=W3C |date=12 August 2014 |accessdate=18 August 2014}}</ref>
|url=http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060405/ |archiveurl=https://web.archive.org/web/20080516060525/http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060405/ |title=The XMLHttpRequest Object |publisher=World Wide Web Consortium |date=05 April 2006 |archivedate=16 May 2008 |accessdate=18 August 2014}}</ref> The standard was created, and as of August 2014 it is still maintained by the W3C.<ref name="XHRLivingStand">{{cite web |url=http://xhr.spec.whatwg.org/ |title=XMLHttpRequest Living Standard |publisher=W3C |date=12 August 2014 |accessdate=18 August 2014}}</ref>


==Technologies==
==Technologies==
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 that the following technologies are incorporated<ref name="APGarrett05" />:
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<ref name="APGarrett05" />:
* HTML (or XHTML) and CSS for presentation
* HTML (or XHTML) and CSS for presentation
* The Document Object Model (DOM) for dynamic display of and interaction with data
* The Document Object Model (DOM) for dynamic display of and interaction with data
Line 20: Line 20:
* JavaScript to bring these technologies together
* JavaScript to bring these technologies together


Since then, however, there have been a number of developments in the technologies used in an Ajax application and the definition of the term Ajax. XML is not required for data interchange and XSLT is not required for the manipulation of data. |JavaScript Object Notation (JSON) is often used as an alternative format for data interchange,<ref name="tapestry">{{cite Web
Since then, however, there have been a number of developments in the technologies used in an Ajax application and the definition of the term Ajax. XML is not required for data interchange and XSLT is not required for the manipulation of data. |JavaScript Object Notation (JSON) is often used as an alternative format for data interchange<ref name="TapestryJSON">{{cite web |url=http://tapestry.apache.org/tapestry4.1/ajax/json.html |archiveurl=https://web.archive.org/web/20080616113121/http://tapestry.apache.org/tapestry4.1/ajax/json.html |title=JSON - JavaScript Object Notation |publisher=Apache Software Foundation |date=12 February 2008 |archivedate=16 June 2008 |accessdate=18 August 2014}}</ref>, although other formats such as pre-formatted HTML or plain text can also be used.<ref name="DevXJSON">{{cite web |url=http://www.devx.com/Webdev/Article/32651 |archiveurl=https://web.archive.org/web/20080704134131/http://www.devx.com/Webdev/Article/32651 |title=Speed Up Your Ajax-based Apps with JSON |work=DevX.com |author=Lacava, Alessandro |publisher=Jupitermedia Corporation |date=05 October 2006 |archivedate=04 July 2008 |accessdate=18 August 2014}}</ref>
| url=http://tapestry.apache.org/tapestry4.1/ajax/json.html
| title=JavaScript Object Notation
| publisher=Apache.org
| accessdate=4 July 2008
| archiveurl=https://Web.archive.org/Web/20080616113121/http://tapestry.apache.org/tapestry4.1/ajax/json.html
| archivedate=16 June 2008 <!--DASHBot-->
| deadurl=no}}</ref> although other formats such as preformatted HTML or plain text can also be used.<ref name="devx-json">{{cite Web
| url=http://www.devx.com/Webdev/Article/32651
| title=Speed Up Your Ajax-based Apps with JSON
| publisher=DevX.com
| accessdate=4 July 2008| archiveurl=https://Web.archive.org/Web/20080704134131/http://www.devx.com/Webdev/Article/32651
| archivedate=4 July 2008 <!--DASHBot-->
| deadurl=no}}</ref>


[http://microformats.org/wiki/rest/ahah Asynchronous HTML and HTTP] (AHAH) involves using XMLHTTPRequest to retrieve (X)HTML fragments, which are then inserted directly into the Web page.
==Drawbacks==
Some web developers have identified drawbacks to using Ajax, past and present. Examples include:


== Drawbacks ==
* 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.<ref name="InterWhyAjax">{{cite web
* 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, but may have instead returned to the last full page visited before it. Such behavior&nbsp;— navigating between pages instead of navigating between page states&nbsp;— may be desirable, but if fine-grained tracking of page state is required, then a pre-[[HTML5]] workaround was to use 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.<ref name="interakt">{{cite web
|url=http://www.interaktonline.com/support/articles/Details/Ajax:+Asynchronously+Moving+Forward-Why+use+Ajax%3F.html?id_art=36&id_asc=309 |archiveurl=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 |title=Why use AJAX? |publisher=InterAKT |date=10 November 2005 |archivedate=29 May 2008 |accessdate=26 June 2008}}</ref><ref name="LiDLinkAjax">{{cite web |url=http://blog.onthewings.net/2009/04/08/deep-linking-for-ajax/ |title=Deep Linking for AJAX |work=Andy Li's Blog |author=Li, Andy |date=08 April 2009 |accessdate=18 August 2014}}</ref> HTML provides an extensive API standard for working with the browser's history engine.<ref name="HTML4Spec">{{cite web |url=http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#history |title=7.5 Session history and navigation |work=HTML Specification |publisher=WHATWG |date=06 August 2014 |accessdate=18 October 2014}}</ref>
| url=http://www.interaktonline.com/support/articles/Details/Ajax:+Asynchronously+Moving+Forward-Why+use+Ajax%3F.html?id_art=36&id_asc=309
 
| title=Why use Ajax?
* 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.<ref name="InterWhyAjax" /><ref name="LiDLinkAjax" /> The solution provided by HTML5 for the above problem also applies for this.<ref name="HTML4Spec" />
| publisher=InterAKT
 
| date=10 November 2005
* 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.
| accessdate=26 June 2008
 
| archiveurl=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
* Most Web crawlers do not execute JavaScript code<ref name="IBM">{{cite web |url=http://www.ibm.com/developerworks/library/x-sitemaps/index.html |title=Help Web crawlers efficiently crawl your portal sites and Web sites |work=developerWorks |publisher=IBM |author=Prokoph, Andreas |date=08 May 2007 |accessdate=18 August 2014}}</ref>, so in order to be indexed by search engines, a Web application must provide an alternative means of accessing the content that would normally be retrieved with Ajax.
| archivedate=29 May 2008 <!--DASHBot-->
 
| deadurl=no}}</ref><ref name="deepLinkAjax">{{cite web
* Any user whose browser does not support JavaScript or XMLHttpRequest, or simply has this functionality disabled, will not be able to properly use pages which depend on Ajax. Devices such as smartphones may not have support for the required technologies, though this is becoming less of a problem. The only way to let the user carry out functionality is to fall back to non-JavaScript methods. This can be achieved by making sure links and forms can be resolved properly and not relying solely on Ajax.<ref name="QuinseyAjax">{{cite web |url=http://www.alistapart.com/articles/userproofingajax |title=User-Proofing Ajax |work=A List Apart |author=Quinsey, Peter |date=05 December 2006 |accessdate=18 August 2014}}</ref>
| url=http://blog.onthewings.net/2009/04/08/deep-linking-for-ajax/
 
| title=Deep Linking for AJAX}}</ref> [[HTML5]] provides an extensive [[API]] standard for working with the browser's history engine.<ref name="html5-1">{{Cite web
* 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.<ref name="WAI_ARIA">{{cite web |url=http://www.w3.org/WAI/intro/aria.php |archiveurl=https://web.archive.org/web/20101026062837/http://www.w3.org/WAI/intro/aria.php |title=WAI-ARIA Overview |author=Henry, Shawn Lawton |publisher=W3C |date=September 2010 |archivedate=26 October 2010 |accessdate=18 August 2014}}</ref>
| url=http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html|title=HTML5 specification
 
| accessdate=21 October 2011}}</ref>
* Screen readers that are able to use Ajax may still not be able to properly read the dynamically generated content.<ref name="EdwardsScreenWork">{{cite web |url=http://www.sitepoint.com/ajax-screenreaders-work/ |title=Ajax and Screenreaders: When Can it Work? |author=Edwards, James |publisher=SitePoint |date=05 May 2006 |accessdate=18 August 2014}}</ref>
* [[Dynamic web page|Dynamic Web page]] updates also make it difficult to [[Internet bookmark|bookmark]] and return to a particular state of the application. Solutions to this problem exist, many of which again use the URL fragment identifier.<ref name=interakt/><ref name=deepLinkAjax/> The solution provided by HTML5 for the above problem also applies for this.<ref name=html5-1/>
 
* 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 popup is forthcoming, and if the internet connection is slow, the popup list may show up at an inconvenient time, when the user has already proceeded to do something else.
* The same-origin policy prevents some Ajax techniques from being used across domains<ref name="XHRStand" />, although the W3C has a draft of the XMLHttpRequest object that would enable this functionality.<ref name="W3CAccessControl">{{cite web |url=https://dvcs.w3.org/hg/cors/raw-file/tip/Overview.html |title=Cross-Origin Resource Sharing |publisher=W3C |date=11 June 2012 |accessdate=18 August 2014}}</ref> Methods exist to sidestep this security feature by using a special Cross Domain Communications channel embedded as an iframe within a page<ref name="CrossDomainComm">{{cite web |url=http://msdn.microsoft.com/en-us/library/bb735305.aspx |title=Secure Cross-Domain Communication in the Browser |work=The Architecture Journal |author=Thorpe, Danny |publisher=Microsoft |date=July 2007 |accessdate=18 August 2014}}</ref> or by the use of JSONP.
* Most [[Web crawler]]s do not execute JavaScript code,<ref name="IBM">{{cite web
 
| url=http://www.ibm.com/developerworks/library/x-sitemaps/index.html
* The asynchronous callback-style of programming required can lead to complex code that is hard to maintain, to debug<ref name="CuthAsynch">{{cite web |url=http://gfxmonk.net/2010/07/04/defer-taming-asynchronous-javascript-with-coffeescript.html#1 |title=What is asynchronous programming, and why is it so damn awkward? |work=defer: Taming asynchronous javascript with CoffeeScript |author=Cuthbertson, Tim |date=04 July 2010 |accessdate=18 August 2014}}</ref>, and to test.<ref name="FetchSelen">{{cite web |url=http://seleniumhq.org/docs/03_webdriver.html#fetching-a-page |title=Selenium-WebDriver API Commands and Operations |work=Selenium WebDriver |publisher=Selenium Project |date=31 July 2014 |accessdate=18 August 2014}}</ref> 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.<ref name="WaitSelen">{{cite web |url=http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp |title=WebDriver: Advanced Usage |work=Selenium WebDriver |publisher=Selenium Project |date=31 July 2014 |accessdate=18 August 2014}}</ref>
| title=Help Web crawlers efficiently crawl your portal sites and Web sites
| publisher=[[IBM]]
| first=Andreas
| last=Prokoph
| date=8 May 2007
| accessdate=22 April 2009}}</ref> so in order to be indexed by [[search engines]], a Web application must provide an alternative means of accessing the content that would normally be retrieved with Ajax.
* Any user whose browser does not support JavaScript or <code>XMLHttpRequest</code>, or simply has this functionality disabled, will not be able to properly use pages which depend on Ajax. Devices such as [[smartphone]]s and [[PDA]]s may not have support for the required technologies, though this is becoming less of a problem. The only way to let the user carry out functionality is to fall back to non-JavaScript methods. This can be achieved by making sure links and forms can be resolved properly and not relying solely on Ajax.<ref>{{cite web
| url=http://www.alistapart.com/articles/userproofingajax
| title=User-proofing Ajax
| first=Peter
| last=Quinsey}}</ref>
* Similarly, some Web applications that use Ajax are built in a way that cannot be read by screen-reading technologies, such as [[JAWS (screen reader)|JAWS]]. The [[WAI-ARIA]] standards provide a way to provide hints in such a case.<ref name="WAI_ARIA">{{cite web
| url=http://www.w3.org/WAI/intro/aria.php
| title=WAI-ARIA Overview
| publisher=http://www.w3.org/
| accessdate=21 October 2010
| archiveurl=https://web.archive.org/web/20101026062837/http://www.w3.org/WAI/intro/aria.php
| archivedate=26 October 2010 <!--DASHBot-->
| deadurl= no}}</ref>
* Screen readers that are able to use Ajax may still not be able to properly read the dynamically generated content.<ref name="sitepoint">{{cite web
| url=http://articles.sitepoint.com/article/ajax-screenreaders-work
| title=Ajax and Screenreaders: When Can it Work?
| publisher=[[sitepoint.com]]
| first=James
| last=Edwards
| date=5 May 2006
| accessdate=27 June 2008}}</ref>
* The [[same origin policy]] prevents some Ajax techniques from being used across domains,<ref name="xhr-standard" /> although the W3C has a draft of the XMLHttpRequest object that would enable this functionality.<ref name="xdr">{{cite web
| url=http://dev.w3.org/2006/waf/access-control/
| title=Access Control for Cross-Site Requests
| publisher=World Wide Web Consortium
| accessdate=27 June 2008
| archiveurl=https://web.archive.org/web/20080514034546/http://dev.w3.org/2006/waf/access-control/
| archivedate=14 May 2008 <!--DASHBot-->
| deadurl= no}}</ref> Methods exist to sidestep this security feature by using a special Cross Domain Communications channel embedded as an iframe within a page,<ref name="CrossDomainCommunication">{{cite web
| url=http://msdn.microsoft.com/en-us/library/bb735305.aspx
| title=Secure Cross-Domain Communication in the Browser
| publisher=The Architecture Journal (MSDN)
| accessdate=27 April 2010
| archiveurl=https://web.archive.org/web/20100329064533/http://msdn.microsoft.com/en-us/library/bb735305.aspx
| archivedate=29 March 2010 <!--DASHBot-->| deadurl= no}}</ref> or by the use of [[JSONP#JSONP|JSONP]].
* The asynchronous [[Callback (computer programming)|callback-style of programming]] required can lead to complex code that is hard to maintain, to debug<ref name="async_wrong">{{cite web
| url=http://gfxmonk.net/2010/07/04/defer-taming-asynchronous-javascript-with-coffeescript.html#1
| title=What is asynchronous programming, and why is it so damn awkward?
| publisher=http://gfxmonk.net/
| first=Tim
| last=Cuthbertson
| accessdate=19 October 2010}}
</ref> and to test.<ref name="selenium">{{cite web
| url=http://seleniumhq.org/docs/03_webdriver.html#fetching-a-page
| title=Selenium documentation: Fetching a Page
| publisher=http://seleniumhq.org/
| accessdate=6 October 2011 }}<br />It is worth noting that 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.</ref>


==External links==
==External links==
* [http://www.adaptivepath.com/ideas/ajax-new-approach-web-applications/ Ajax: A New Approach to Web Applications]&nbsp;— Article that coined the AJAX term and Q&A
* {{dmoz|Computers/Programming/Languages/JavaScript/Ajax}}
* [http://www.xul.fr/en-xml-ajax.html Ajax Tutorial] with GET, POST, text and XML examples.
* [http://www.xul.fr/en-xml-ajax.html Ajax Tutorial] with GET, POST, text and XML examples.
==Notes==
Numerous elements of this article are reused from [http://en.wikipedia.org/wiki/Ajax_%28programming%29 the Wikipedia article].


==References==
==References==
<references />
<references />
<!---Place all category tags here-->
[[Category:Software and hardware terms]]

Latest revision as of 17:03, 22 August 2014

Ajax (also AJAX) is a group of interrelated Web development techniques used on the client-side to create asynchronous Web applications. With Ajax, Web applications can send data to and retrieve data from a server asynchronously (in the background) without interfering with the display and behavior of the existing page. Data can be retrieved using the XMLHttpRequest object and API (application programming interface). Despite the name, the use of XML is not required; JavaScript Object Notation (JSON) is often used instead, and the requests do not need to be asynchronous.[1]

Ajax is a group of technologies. HTML and CSS can be used in combination to mark up and style information. The Document Object Model (DOM) is accessed with JavaScript to dynamically display – and allow the user to interact with – the information presented. JavaScript and the XMLHttpRequest object provide a method for exchanging data asynchronously between browser and server to avoid full page reloads.

History

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 iframe tag in 1996, the first XMLHTTP component in 1998, and an XMLHTTP ActiveX control in 1999 that years later was adopted by Mozilla, Safari, Opera, and other browsers as the XMLHttpRequest JavaScript object.[2]

By the mid-2000s, the idea of using XML within HTTP requests began to truly take shape. Microsoft had already worked on adding this sort of functionality into its Outlook Web Access for Exchange in the early 2000s, and Google followed suit with it Gmail and Google Maps products in 2004 and 2005 respectively.[3][4][5] And in October 2004 the public beta release of Kayak.com was among the first large-scale e-commerce applications of the technology, what their developers at that time called "the xml http thing."[6] The set of technologies would formally stick with the name "Ajax," an acronym for "asynchronous JavaScript and XML," and be described by Adaptive Path's founder and president Jesse James Garrett in February 2005 as "several technologies, each flourishing in its own right, coming together in powerful new ways."[5][1]

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.[7] The standard was created, and as of August 2014 it is still maintained by the W3C.[8]

Technologies

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[5]:

  • 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
  • JavaScript to bring these technologies together

Since then, however, there have been a number of developments in the technologies used in an Ajax application and the definition of the term Ajax. XML is not required for data interchange and XSLT is not required for the manipulation of data. |JavaScript Object Notation (JSON) is often used as an alternative format for data interchange[9], although other formats such as pre-formatted HTML or plain text can also be used.[10]

Drawbacks

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.[11][12] HTML provides an extensive API standard for working with the browser's history engine.[13]
  • 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.[11][12] The solution provided by HTML5 for the above problem also applies for this.[13]
  • 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.
  • Most Web crawlers do not execute JavaScript code[14], so in order to be indexed by search engines, a Web application must provide an alternative means of accessing the content that would normally be retrieved with Ajax.
  • Any user whose browser does not support JavaScript or XMLHttpRequest, or simply has this functionality disabled, will not be able to properly use pages which depend on Ajax. Devices such as smartphones may not have support for the required technologies, though this is becoming less of a problem. The only way to let the user carry out functionality is to fall back to non-JavaScript methods. This can be achieved by making sure links and forms can be resolved properly and not relying solely on Ajax.[15]
  • 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.[16]
  • Screen readers that are able to use Ajax may still not be able to properly read the dynamically generated content.[17]
  • The same-origin policy prevents some Ajax techniques from being used across domains[7], although the W3C has a draft of the XMLHttpRequest object that would enable this functionality.[18] Methods exist to sidestep this security feature by using a special Cross Domain Communications channel embedded as an iframe within a page[19] 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[20], and to test.[21] 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.[22]

External links

Notes

Numerous elements of this article are reused from the Wikipedia article.

References

  1. 1.0 1.1 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. 
  2. "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. 
  3. 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. 
  4. Swartz, Aaron (22 December 2005). "A Brief History of Ajax". Raw Thought. http://www.aaronsw.com/weblog/ajaxhistory. Retrieved 18 August 2014. 
  5. 5.0 5.1 5.2 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. 
  6. 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. 
  7. 7.0 7.1 "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. 
  8. "XMLHttpRequest Living Standard". W3C. 12 August 2014. http://xhr.spec.whatwg.org/. Retrieved 18 August 2014. 
  9. "JSON - JavaScript Object Notation". Apache Software Foundation. 12 February 2008. Archived from the original on 16 June 2008. https://web.archive.org/web/20080616113121/http://tapestry.apache.org/tapestry4.1/ajax/json.html. Retrieved 18 August 2014. 
  10. 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. 
  11. 11.0 11.1 "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. 
  12. 12.0 12.1 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. 
  13. 13.0 13.1 "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. 
  14. 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. 
  15. Quinsey, Peter (5 December 2006). "User-Proofing Ajax". A List Apart. http://www.alistapart.com/articles/userproofingajax. Retrieved 18 August 2014. 
  16. 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. 
  17. Edwards, James (5 May 2006). "Ajax and Screenreaders: When Can it Work?". SitePoint. http://www.sitepoint.com/ajax-screenreaders-work/. Retrieved 18 August 2014. 
  18. "Cross-Origin Resource Sharing". W3C. 11 June 2012. https://dvcs.w3.org/hg/cors/raw-file/tip/Overview.html. Retrieved 18 August 2014. 
  19. 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. 
  20. Cuthbertson, Tim (4 July 2010). "What is asynchronous programming, and why is it so damn awkward?". defer: Taming asynchronous javascript with CoffeeScript. http://gfxmonk.net/2010/07/04/defer-taming-asynchronous-javascript-with-coffeescript.html#1. Retrieved 18 August 2014. 
  21. "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. 
  22. "WebDriver: Advanced Usage". Selenium WebDriver. Selenium Project. 31 July 2014. http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp. Retrieved 18 August 2014.