<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Nicolae Sfetcu</title>
  <subtitle>My virtual house and friends</subtitle>
  <link rel="alternate" type="text/html" href="http://www.sfetcu.com/content/Ajax"/>
  <link rel="self" type="application/atom+xml" href="http://www.sfetcu.com/node/1147/atom/feed"/>
  <id>http://www.sfetcu.com/node/1147/atom/feed</id>
  <updated>2008-07-04T14:18:54-06:00</updated>
  <entry>
    <title>Ajax</title>
    <link rel="alternate" type="text/html" href="http://www.sfetcu.com/content/Ajax" />
    <id>http://www.sfetcu.com/content/Ajax</id>
    <published>2008-07-04T14:18:54-06:00</published>
    <updated>2008-07-04T14:18:54-06:00</updated>
    <author>
      <name>nicolae</name>
    </author>
    <category term="advantages" />
    <category term="Ajax" />
    <category term="Asynchronous JavaScript" />
    <category term="b" />
    <category term="constituent technologies" />
    <category term="CSS" />
    <category term="DHTML" />
    <category term="DOM" />
    <category term="ECMAScript" />
    <category term="Guides" />
    <category term="history" />
    <category term="HTML" />
    <category term="Javascript" />
    <category term="JScript" />
    <category term="JSON" />
    <category term="justification" />
    <category term="LAMP" />
    <category term="SPA" />
    <category term="technique" />
    <category term="technologies" />
    <category term="web applications" />
    <category term="Web design and development" />
    <category term="web development" />
    <category term="XHTML" />
    <category term="XML" />
    <category term="XMLHttpRequest" />
    <summary type="html"><![CDATA[<p><img src="http://www.sfetcu.com/sites/default/files/images/Ajax_Frameworks.preview.jpg" alt="Ajax Frameworks" title="Ajax Frameworks" class="image image-preview" width="468" height="351" longdesc="http://www.flickr.com/photos/u-suke/154833137/" /></p>
<p><b>Ajax</b>, or <b>AJAX</b>, is a web development technique used for creating  interactive web applications. The intent is to make web pages feel more  responsive by exchanging small amounts of data with the server behind the  scenes, so that the entire web page does not have to be reloaded each time the  user requests a change. This is intended to increase the web page's  interactivity, speed, functionality, and usability.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p><img src="http://www.sfetcu.com/sites/default/files/images/Ajax_Frameworks.preview.jpg" alt="Ajax Frameworks" title="Ajax Frameworks" class="image image-preview" width="468" height="351" longdesc="http://www.flickr.com/photos/u-suke/154833137/" /></p>
<p><b>Ajax</b>, or <b>AJAX</b>, is a web development technique used for creating  interactive web applications. The intent is to make web pages feel more  responsive by exchanging small amounts of data with the server behind the  scenes, so that the entire web page does not have to be reloaded each time the  user requests a change. This is intended to increase the web page's  interactivity, speed, functionality, and usability.</p>
<p>The name is shorthand for <i>Asynchronous JavaScript and XML</i>. Ajax is  asynchronous in that loading does not interfere with normal page loading.  JavaScript is the programming language in which Ajax function calls are made.  Data retrieved using the technique is commonly formatted using XML, as reflected  in the naming of the <i>XMLHttpRequest</i> object from which Ajax is derived.</p>
<p>Ajax is a cross-platform technique usable on many different operating  systems, computer architectures, and Web browsers as it is based on open  standards such as JavaScript and XML, together with open source implementations  of other required technologies.</p>
<h2><span class="mw-headline">Constituent technologies</span></h2>
<p>Ajax uses a combination of:</p>
<ul>
<li>XHTML (or HTML) and CSS, for marking up and styling information.</li>
<li>The DOM accessed with a client-side scripting language, especially  	ECMAScript implementations such as JavaScript and JScript, to dynamically  	display and interact with the information presented.</li>
<li>The XMLHttpRequest object is used to exchange data asynchronously with  	the web server. In some Ajax frameworks and in certain situations, an IFrame  	object is used instead of the XMLHttpRequest object to exchange data with  	the web server, and in other implementations, dynamically added <code> 	&lt;script&gt;</code> tags may be used.</li>
<li>XML is sometimes used as the format for transferring data between the  	server and client, although any format will work, including preformatted  	HTML, plain text and JSON. These files may be created dynamically by some  	form of server-side scripting.</li>
</ul>
<p>Like DHTML, LAMP, and SPA, Ajax is not a technology in itself, but a term  that refers to the use of a group of technologies.</p>
<p>The &quot;core&quot; and defining element of Ajax is the XMLHttpRequest object, which  gives browsers the ability to make dynamic and asynchronous data requests  without having to unload and reload a page. Given XMLHttpRequest can eliminate  the need for page refreshes, other technologies have become more prominently  used and highlighted with this development approach.</p>
<p>Besides XMLHttpRequest, the use of DOM, CSS, and JavaScript provides a  more-enhanced &quot;single-page&quot; experience.</p>
<h2><span class="mw-headline">History</span></h2>
<p>The first use of the term in public was by Jesse James Garrett in February  2005. Garrett thought of the term when he realized the need for a shorthand term  to represent the suite of technologies he was proposing to a client.</p>
<p>Although the term <i>Ajax</i> was coined in 2005, most of the technologies  that enable Ajax started a decade earlier with Microsoft's initiatives in  developing Remote Scripting. Referring to the idea as Inner-Browsing, Netscape  Evangelism published an article in 2003 which presented ideas for implementing  models in which &quot;all navigation occurs within a single page, as in a typical  application interface.&quot;[2] Techniques for the asynchronous loading of content on  an existing Web page without requiring a full reload date back as far as the  IFRAME element type (introduced in Internet Explorer 3 in 1996) and the LAYER  element type (introduced in Netscape 4 in 1997, abandoned during early  development of Mozilla). Both element types had a src attribute that could take  any external URL, and by loading a page containing JavaScript that manipulated  the parent page, Ajax-like effects could be attained. This set of client-side  technologies was usually grouped together under the generic term of DHTML.  Macromedia's Flash could also, from version 4, load XML and CSV files from a  remote server without requiring a browser to be refreshed.</p>
<p>Microsoft's Remote Scripting (MSRS), introduced in 1998, acted as a more  elegant replacement for these techniques, with data being pulled in by a Java  applet with which the client side could communicate using JavaScript. This  technique worked on both Internet Explorer version 4 and Netscape Navigator  version 4 onwards. Microsoft then created the XMLHttpRequest object in Internet  Explorer version 5 and first took advantage of these techniques using  XMLHttpRequest in Outlook Web Access supplied with the Microsoft Exchange Server  2000 release.</p>
<p>The Web development community, first collaborating via the <i> microsoft.public.scripting.remote</i> newsgroup and later through blog  aggregation, subsequently developed a range of techniques for remote scripting  to enable consistent results across different browsers. In 2002, a  user-community modification to Microsoft Remote Scripting was made to replace  the Java applet with XMLHttpRequest.</p>
<p>Remote Scripting Frameworks such as ARSCIF surfaced in 2003 not long before  Microsoft introduced Callbacks in ASP.NET.</p>
<p>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 would include:</p>
<ul>
<li>The object element defined in HTML 4 for embedding arbitrary content  	types into documents, (replaces inline frames under XHTML 1.1)</li>
<li>The Document Object Model (DOM) Level 3 Load and Save Specification 	<a href="http://www.w3.org/TR/DOM-Level-3-LS/" rel="nofollow" title="http://www.w3.org/TR/DOM-Level-3-LS/" class="external autonumber"> 	[1]</a></li>
</ul>
<h2><span class="mw-headline">Justification</span></h2>
<p>The core justification for Ajax style programming is to overcome the page  loading requirements of HTML/HTTP-mediated web pages. Ajax creates the necessary  initial conditions for the evolution of complex, intuitive, dynamic,  data-centric user interfaces in web pages&mdash;the realization of that goal is still  a work in progress.</p>
<p>Web pages, unlike native applications, are loosely coupled, meaning that the  data they display are not tightly bound to data sources and must be first  marshaled (set out in proper order) into an HTML page format before they can be  presented to a user agent on the client machine. For this reason, web pages have  to be re-loaded each time a user needs to view different datasets. By using the  XMLHttpRequest object to request and return data without a re-load, a programmer  by-passes this requirement and makes the loosely coupled web page behave much  like a tightly coupled application, but with a more variable lag time for the  data to pass through a longer &quot;wire&quot; to the remote web browser.</p>
<p>For example, in a classic desktop application, a programmer has the choice of  populating a tree view control with all the data needed when the form initially  loads, or with just the top-most level of data&mdash;which would load more quickly,  especially when the dataset is very large. In the second case, the application  would fetch additional data into the tree control depending on which item the  user selects. This functionality is difficult to achieve in a web page without  Ajax. To update the tree based on a user's selection would require the entire  page to re-load, leading to a very jerky, non-intuitive feel for the web user  who is browsing the data in the tree.</p>
<h2><span class="mw-headline">Advantages of Ajax</span></h2>
<h3><span class="mw-headline">Bandwidth usage</span></h3>
<p>By generating the HTML locally within the browser, and only bringing down  JavaScript calls and the actual data, Ajax web pages can appear to load  relatively quickly since the payload coming down is much smaller in size. An  example of this technique is a large result set where multiple pages of data  exist. With Ajax, the HTML of the page (e.g., a table structure with related TD  and TR tags) can be produced locally in the browser and not brought down with  the first page of the document.</p>
<p>In addition to &quot;load on demand&quot; of contents, some web-based applications load  stubs of event handlers and then load the functions on the fly. This technique  significantly cuts down the bandwidth consumption for web applications that have  complex logic and functionality.</p>
<h3><span class="mw-headline">Separation of data, format, style, and function</span></h3>
<p>A less specific benefit of the Ajax approach is that it tends to encourage  programmers to clearly separate the methods and formats used for the different  aspects of information delivery via the web. Although Ajax can appear to be a  jumble of languages and techniques, and programmers are free to adopt and adapt  whatever works for them, they are generally propelled by the development motive  itself to adopt separation among the following:</p>
<ol>
<li>Raw data or content to be delivered, which is normally embedded in XML  	and sometimes derived from a server-side database.</li>
<li>Format or structure of the webpage, which is almost always built in HTML  	or XHTML and is then reflected and made available to dynamic manipulation in  	the DOM.</li>
<li>Style elements of the webpage: everything from fonts to picture  	placement are derived by reference to embedded or referenced CSS.</li>
<li>Functionality of the webpage, which is provided by a combination of:
<ol>
<li>Javascript on the client browser (also called DHTML),</li>
<li>Standard HTTP and XMLHttp or client-to-server communication, and</li>
<li>Server-side scripting and/or programs using any suitable language  		preferred by the programmer to receive the client's specific requests  		and respond appropriately.</li>
</ol>
</li>
</ol>
<h2><span class="mw-headline">Disadvantages</span></h2>
<h3><span class="mw-headline">Browser integration</span></h3>
<p><i>The dynamically created page does not register itself with the browser  history engine, so triggering the &quot;Back&quot; function of the users' browser might  not bring the desired result.</i></p>
<p>Developers have implemented various solutions to this problem. These  solutions can involve using invisible IFRAMEs to invoke changes that populate  the history used by a browser's back button. Google Maps, for example, performs  searches in an invisible IFRAME and then pulls results back into an element on  the visible web page. The World Wide Web Consortium (W3C) did not include an <i> iframe</i> element in its XHTML 1.1 Recommendation; the Consortium recommends  the <i>object</i> element instead.</p>
<p>Another issue is that dynamic web page updates make it difficult for a user  to bookmark a particular state of the application. Solutions to this problem  exist, many of which use the URL fragment identifier (the portion of a URL after  the '#') to keep track of, and allow users to return to, the application in a  given state. This is possible because many browsers allow JavaScript to update  the fragment identifier of the URL dynamically, so that Ajax applications can  maintain it as the user changes the application's state. This solution also  improves back-button support. It is, however, not a complete solution.</p>
<h3><span class="mw-headline">Response-time concerns</span></h3>
<p>Network latency &mdash; or the interval between user request and server response &mdash;  needs to be considered carefully during Ajax development. Without clear feedback  to the user,[8] smart preloading of data and proper handling of the  XMLHttpRequest object, users might experience delays in the interface of the web  application, something which they might not expect or understand. Additionally,  when an entire page is rendered there is a brief moment of re-adjustment for the  eye when the content changes. The lack of this re-adjustment with smaller  portions of the screen changing makes the latency more apparent. The use of  visual feedback (such as throbbers) to alert the user of background activity  and/or preloading of content and data are often suggested solutions to these  latency issues.</p>
<h3><span class="mw-headline">Search engine optimization</span></h3>
<p>Websites that use Ajax to load data which should be indexed by search engines  must be careful to provide equivalent Sitemaps data at a public, linked URL that  the search engine can read, as search engines do not generally execute the  JavaScript code required for Ajax functionality. This problem is not specific to  Ajax, as the same issue occurs with sites that provide dynamic data as a  full-page refresh in response to, say, a form submit (the general problem is  sometimes called the hidden, or deep web).</p>
<h3><span class="mw-headline">Reliance on JavaScript</span></h3>
<p>Ajax relies on JavaScript, which is often implemented differently by  different browsers or versions of a particular browser. Because of this, sites  that use JavaScript may need to be tested in multiple browsers to check for  compatibility issues. It's not uncommon to see JavaScript code written twice,  one part for IE, another part for Mozilla compatibles, although this is less  true with the release of IE7 and with the now-common use of JavaScript  abstraction libraries like the Prototype JavaScript Framework. Such libraries  abstract browser-specific differences from the web developer.</p>
<p>The level of IDE support for JavaScript used to be poor, although is changing  with more wide-spread use of tools like firebug, IE Developer Toolbar and  Venkman.</p>
<p>An issue also arises if the user has switched off JavaScript support in the  browser, thus disabling the functionality built into the page.</p>
<h3><span class="mw-headline">Web analytics</span></h3>
<p>Many web analytics solutions are based on the paradigm of a new page being  loaded whenever new or updated content is displayed to the user, or to track a  series of steps in a process such as a check-out. Since Ajax alters this  process, care must be taken to account for how to instrument a page or a portion  of a page so that it can be accurately tracked. Analytics systems which allow  for the tracking of events other than a simple page view, such as the click of a  button or link, are the ones most likely to be able to accommodate a site which  heavily utilizes Ajax.</p>
<h2><span class="mw-headline">Accessibility</span></h2>
<p>Non-Ajax users would ideally continue to load and manipulate the whole page  as a fallback, enabling the developers to preserve the experience of users in  non-Ajax environments (including all relevant accessibility concerns) while  giving those with capable browsers a much more responsive experience.</p>
<h2><span class="mw-headline">References</span></h2>
<ol class="references">
<li id="_note-garrett"><b> 	<a href="file:///I:/www/webdev/webdev/Ajax.html#_ref-garrett_0" title="">^</a></b> 	<a href="http://www.adaptivepath.com/publications/essays/archives/000385.php" rel="nofollow" title="http://www.adaptivepath.com/publications/essays/archives/000385.php" class="external text"> 	Ajax: A New Approach to Web Applications</a>. 	<a href="http://en.wikipedia.org/w/index.php?title=Adaptive_Path&amp;action=edit" title="Adaptive Path" class="new"> 	Adaptive Path</a> (2005-02-18).</li>
<li id="_note-0"><b> 	<a href="file:///I:/www/webdev/webdev/Ajax.html#_ref-0" title="">^</a></b> 	<a href="http://devedge-temp.mozilla.org/viewsource/2003/inner-browsing/index_en.html" rel="nofollow" title="http://devedge-temp.mozilla.org/viewsource/2003/inner-browsing/index_en.html" class="external text"> 	Inner-Browsing: Extending the Browsing Navigation Paradigm</a>. Netscape  	Netscape (2003-05-16).</li>
<li id="_note-1"><b> 	<a href="file:///I:/www/webdev/webdev/Ajax.html#_ref-1" title="">^</a></b> 	<a href="http://groups.google.ca/group/microsoft.public.scripting.remote/browse_thread/thread/99b7e6152b45b2e7/6b3689e2dc7401dc" rel="nofollow" title="http://groups.google.ca/group/microsoft.public.scripting.remote/browse_thread/thread/99b7e6152b45b2e7/6b3689e2dc7401dc" class="external text"> 	HTTPRequest-enabled RS</a>. microsoft.public.scripting.remote newsgroup  	(2002-06-18).</li>
<li id="_note-2"><b> 	<a href="file:///I:/www/webdev/webdev/Ajax.html#_ref-2" title="">^</a></b> 	<a href="http://arscif.dsi.unimi.it/" rel="nofollow" title="http://arscif.dsi.unimi.it/" class="external text"> 	ARSCIF: A Framework for Asynchronous Remote&ndash;Script Callback Invocation</a>.  	Sebastiano Vigna.</li>
<li id="_note-3"><b> 	<a href="file:///I:/www/webdev/webdev/Ajax.html#_ref-3" title="">^</a></b> 	<a href="http://msdn.microsoft.com/msdnmag/issues/04/08/CuttingEdge/" rel="nofollow" title="http://msdn.microsoft.com/msdnmag/issues/04/08/CuttingEdge/" class="external text"> 	Cutting Edge: Script Callbacks in ASP.NET</a>. MSDN Magazine sujatha reddy  	ambati (2004-08-08).</li>
<li id="_note-rfc2396"><b> 	<a href="file:///I:/www/webdev/webdev/Ajax.html#_ref-rfc2396_0" title="">^</a></b> 	<a href="http://www.ietf.org/rfc/rfc2396.txt" rel="nofollow" title="http://www.ietf.org/rfc/rfc2396.txt" class="external text"> 	Uniform Resource Identifiers (URI): Generic Syntax</a>. The Internet Society  	(August 1998).</li>
<li id="_note-rfc3986"><b> 	<a href="file:///I:/www/webdev/webdev/Ajax.html#_ref-rfc3986_0" title="">^</a></b> 	<a href="http://www.ietf.org/rfc/rfc3986.txt" rel="nofollow" title="http://www.ietf.org/rfc/rfc3986.txt" class="external text"> 	Uniform Resource Identifier (URI): Generic Syntax</a>. The Internet Society  	(January 2005).</li>
<li id="_note-remotescripting"><b> 	<a href="file:///I:/www/webdev/webdev/Ajax.html#_ref-remotescripting_0" title=""> 	^</a></b> 	<a href="http://www.xml.com/pub/a/2005/08/22/ajax.html" rel="nofollow" title="http://www.xml.com/pub/a/2005/08/22/ajax.html" class="external text"> 	Remote Scripting with AJAX, Part 2</a>. O'Reilly XML.com (2005-08-22).</li>
</ol>
<h2><span class="mw-headline">Links</span></h2>
<ul>
<li><a href="http://dmoz.org/Computers/Programming/Languages/JavaScript/AJAX" rel="nofollow" title="http://dmoz.org/Computers/Programming/Languages/JavaScript/AJAX" class="external text"> 	AJAX category</a> on the Open Directory Project.</li>
<li><a href="http://www.adaptivepath.com/publications/essays/archives/000385.php" rel="nofollow" title="http://www.adaptivepath.com/publications/essays/archives/000385.php" class="external text"> 	Jesse James Garrett. &ldquo;Ajax: A New Approach to Web Applications&rdquo;, Adaptive  	Path</a></li>
<li><a href="http://developer.mozilla.org/en/docs/AJAX:Getting_Started" rel="nofollow" title="http://developer.mozilla.org/en/docs/AJAX:Getting_Started" class="external text"> 	AJAX:Getting Started</a> by Mozilla Developer Center.</li>
<li><a href="http://www.xul.fr/en-xml-ajax.html" rel="nofollow" title="http://www.xul.fr/en-xml-ajax.html" class="external text"> 	Ajax Tutorial</a> with get, post, text and XML examples.</li>
<li><a href="http://www.isecpartners.com/files/iSEC-Attacking_AJAX_Applications.BH2006.pdf" rel="nofollow" title="http://www.isecpartners.com/files/iSEC-Attacking_AJAX_Applications.BH2006.pdf" class="external text"> 	Attacking AJAX Applications</a> Presentation on Ajax Security issues given  	at the Black Hat security conference.</li>
</ul>
<p>This guide is licensed under the <a href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a>.  It uses material from the <a href="http://www.wikipedia.org/">Wikipedia</a>.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/XdUFjAvOPU0&hl=en&fs=1" /><param name="allowFullScreen" value="true" /><embed src="http://www.youtube.com/v/XdUFjAvOPU0&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object></p>
    ]]></content>
  </entry>
</feed>
