<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>has_many :thoughts: Tag AJAX</title>
    <link>http://blog.kineticweb.com/articles/tag/ajax</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Musings from a Ruby on Rails development team</description>
    <item>
      <title>request.xhr? is only for Prototype?</title>
      <description>&lt;p&gt;I just found this lovely tid-bit of information in the &lt;a href="http://api.rubyonrails.org/classes/ActionController/AbstractRequest.html#M000407"&gt;ActionController::AbstractRequest&lt;/a&gt; class&amp;#8230;&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_shell "&gt;# Returns true if the request's &amp;quot;X-Requested-With&amp;quot; header contains
# &amp;quot;XMLHttpRequest&amp;quot;. (The Prototype Javascript library sends this header with
# every Ajax request.)
def xml_http_request?
    !(@env['HTTP_X_REQUESTED_WITH'] !~ /XMLHttpRequest/i)
end
alias xhr? :xml_http_request?&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Mental note for later: Make sure to set this header when using jQuery in future projects&amp;#8230;. Not sure if jQuery does this already (probably not).&lt;/p&gt;</description>
      <pubDate>Wed, 26 Mar 2008 13:12:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:cf7dfbc4-7c45-41ed-b53d-24f0aa3e9021</guid>
      <author>Justin Reagor</author>
      <link>http://blog.kineticweb.com/articles/2008/03/26/request-xhr-is-only-for-prototype</link>
      <category>actionpack</category>
      <category>Javascript</category>
      <category>AJAX</category>
    </item>
    <item>
      <title>Working around IE gif annoyances</title>
      <description>&lt;p&gt;Parts of an upcoming project make calls out to an external service that can take several seconds to respond. As everyone knows, the attention span of the average idiot web surfer is closer to a few nano-seconds. And so, we use &lt;span class="caps"&gt;AJAX&lt;/span&gt; loading indicator animated gifs to show the user something is happening.&lt;/p&gt;


	&lt;p&gt;However, several pages perform this call on their initial load. So an &lt;span class="caps"&gt;AJAX&lt;/span&gt; loading indicator won&amp;#8217;t do the trick&amp;#8212;the indicator has to appear on the preceding page in the navigation process. And so, we created some Javascript that would simply unhide an animated gift next to a &amp;#8220;Next Step&amp;#8221; button when the button was clicked. This provides some feedback to user that the next page is loading. (The user could, of course, note the status of their own browser&amp;#8217;s load-indicator, but I suspected many wouldn&amp;#8217;t.)&lt;/p&gt;


	&lt;p&gt;This seemed to be working great until solid IE testing began. We soon discovered that as soon as navigation away from the current page has begun, IE stops all animated gifs. The result is a rather unhelpful seized-up spinner-gif that actually makes the user think something went wrong.&lt;/p&gt;


	&lt;p&gt;So instead of an animated gif, we now use the lovely effect features of &lt;a href="http://script.aculo.us"&gt;script.aculo.us&lt;/a&gt; to fade a non-animated hourglass icon in and out when the button is clicked. Some JS like this&amp;#8230;&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;Effect.Pulsate(icon, {
    duration: 100, 
    pulses: 95
});&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;...results in something like this:&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://blog.kineticweb.com/files/next_step_anim.gif" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;The net result is the same: the user knows something is happening behind the scenes. But now, at least, it plays nice with IE. Seems that IE lets JS effects like this go on even after the call to the next page has begun.&lt;/p&gt;


	&lt;p&gt;In retrospect, it might been best to ensure that our page loads didn&amp;#8217;t call the external service directly. But rather, load the next page rapidly and then made an &lt;span class="caps"&gt;AJAX&lt;/span&gt; call out to trigger the slower service. That way, we could have avoided these issues all together and used the traditional, in-page &lt;span class="caps"&gt;AJAX&lt;/span&gt; loading animated gifs.&lt;/p&gt;


	&lt;p&gt;Oh well. There&amp;#8217;s always version 2.0.&lt;/p&gt;</description>
      <pubDate>Tue, 05 Feb 2008 19:02:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:18e49692-2aed-42a7-9de9-c9460834634d</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2008/02/05/working-around-ie-gif-annoyances</link>
      <category>Javascript</category>
      <category>AJAX</category>
    </item>
    <item>
      <title>Javascript Fu</title>
      <description>&lt;p&gt;Londoner Dan Webb, creator of the UJS4Rails.com website with plugins for Unobtrusive Javascript, presented about some tips and tricks for dealing with Javascript in Rails. He revealed that he&amp;#8217;s not maintaining the Unobtrusive Javascript plugin but instead has been focusing his free cycles on an extension to Prototype called LowPro.&lt;/p&gt;


	&lt;p&gt;I actually had a bit of a hard time following much of the technical nitty gritty of this talk. Mostly because my Javascript skillz are lacking. But also because it was packed as hell and pretty uncomfortable to sit still.&lt;/p&gt;


	&lt;p&gt;Dan did stress that we should all do a better job of making sure our Rails apps at least still function when Javascript is not available. He presented an example of an acquaintance who was unable to use any site using the standard &lt;span class="caps"&gt;AJAX&lt;/span&gt; frameworks because they all used the &lt;code&gt;eval&lt;/code&gt; function of Javascript which the corporate security nazis frown upon.&lt;/p&gt;


	&lt;p&gt;His recommendation was to think about how your app can work, albeit with reduced functionality, when Javascript is not available to the user. One should build their app without any AJAXishy features at first, and then layer on the Javascript, &lt;span class="caps"&gt;AJAX&lt;/span&gt;, and &#8220;interface sheen&#8221; as he called it. I agree, although I think a decision about how much functionality to provide fo non-javascript-enabled browsers needs to be carefully considered in the context of the project at hand.&lt;/p&gt;</description>
      <pubDate>Mon, 21 May 2007 10:56:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:886d46d3-93fe-4f90-985a-0e9107892276</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2007/05/21/javascript-fu</link>
      <category>Javascript</category>
      <category>AJAX</category>
      <category>RailsConf</category>
      <category>RailsConf07</category>
    </item>
  </channel>
</rss>
