<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>John McCollum &#187; AJAX</title>
	<atom:link href="http://johnmc.co/llum/category/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://johnmc.co/llum</link>
	<description>Muddling through since 1980</description>
	<lastBuildDate>Sat, 11 Sep 2010 11:59:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Pro Javascript Techniques by John Resig &#8211; a review</title>
		<link>http://johnmc.co/llum/pro-javascript-techniques-by-john-resig-a-review/</link>
		<comments>http://johnmc.co/llum/pro-javascript-techniques-by-john-resig-a-review/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 12:24:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=88</guid>
		<description><![CDATA[I&#8217;ve just finished reading Pro JavaScript Techniques by John Resig, and I thought I&#8217;d post some thoughts about it. The author, John Resig, is the creator of the popular jQuery library. He also works as a Javascript evangelist for Mozilla, so there&#8217;s no doubt that he&#8217;s one of the best known proponents of the language. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fpro-javascript-techniques-by-john-resig-a-review%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fpro-javascript-techniques-by-john-resig-a-review%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="alignright size-full wp-image-89" title="pro-javascript-techniques" src="http://johnmccollum.co.uk/wp-content/uploads/2009/10/pro-javascript-techniques.jpg" alt="pro-javascript-techniques" width="240" height="240" />I&#8217;ve just finished reading <a href="http://www.amazon.com/gp/product/1590597273?ie=UTF8&amp;tag=johnmccollumc-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1590597273">Pro JavaScript Techniques</a> by John Resig, and I thought I&#8217;d post some thoughts about it.</p>
<p>The author, <a href="http://ejohn.org">John Resig</a>, is the creator of the popular <a href="http://jquery.com">jQuery</a> library. He also works as a Javascript evangelist for <a href="http://www.mozilla.org/">Mozilla</a>, so there&#8217;s no doubt that he&#8217;s one of the best known proponents of the language.</p>
<p>Although I use the jQuery library on a daily basis, I was keen to brush up on some of the finer points of Javascript; my knowledge of the jQuery library probably exceeds my knowledge of Javascript! For this reason, I thought the book sounded good.</p>
<p>The first half of the book certainly doesn&#8217;t disappoint. Covering the nitty-gritty of DOM traversal, OO Javascript, and unobtrusive scripting, the book does a great job of covering a lot of ground in a concise, clear manner. The key concepts are illustrated with plenty of code snippets which do a great job of illuminating the subject matter.</p>
<p>The second part of the book was less useful for me, illustrating some examples of AJAX functionality, image galleries, autocomplete, that sort of thing. These topics might have been considered intermediate to advanced in 2006, when the book was released, but the plethora of options around today means that developing stuff like that now is re-inventing the wheel. (Of course you might be interested in <a href="http://www.codinghorror.com/blog/archives/001145.html">learning more about wheels</a>!)</p>
<p>You can almost see the snippets of code in this book forming the nuts and bolts of the jQuery library, and it&#8217;s interesting to take a look at the hoops we developers would have to jump through to otherwise gain cross-browser compliance.</p>
<p>I&#8217;m just glad I&#8217;m not the one having to negotiate those hoops myself!</p>
<p>To sum up, this book is still worth reading for the first half alone, and the stuff on OO javascript, scoping, closures etc is really useful. But some might consider the book a little out of date, so be warned.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/pro-javascript-techniques-by-john-resig-a-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting Prototype&#8217;s Ajax.PeriodicalUpdater to jQuery</title>
		<link>http://johnmc.co/llum/converting-prototypes-ajaxperiodicalupdater-to-jquery/</link>
		<comments>http://johnmc.co/llum/converting-prototypes-ajaxperiodicalupdater-to-jquery/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 21:54:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=84</guid>
		<description><![CDATA[One of the things I missed when switching from Prototype to jQuery was the former&#8217;s Ajax.PeriodicalUpdater function. It is used to provide a &#8216;decay&#8217; mechanism for ajax calls, making them less and less frequent if the retrieved content doesn&#8217;t change inbetween calls. It can be a seriously useful piece of functionality. I took a chatroom [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fconverting-prototypes-ajaxperiodicalupdater-to-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fconverting-prototypes-ajaxperiodicalupdater-to-jquery%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>One of the things I missed when switching from <a href="http://prototypejs.org">Prototype</a> to <a href="http://jquery.com">jQuery</a> was the former&#8217;s <a href="http://www.prototypejs.org/api/ajax/periodicalUpdater">Ajax.PeriodicalUpdater</a> function. It is used to provide a &#8216;decay&#8217; mechanism for ajax calls, making them less and less frequent if the retrieved content doesn&#8217;t change inbetween calls.</p>
<p>It can be a seriously useful piece of functionality. I took a chatroom that was polling every second and using an entire CPU core (50% usage!) and reduced it to 2-3% using this method. There were also errors retrieving content because sometimes the responses would take longer than a second to come back!</p>
<p>The problem is, there really isn&#8217;t a similar piece of functionality in jQuery.</p>
<p>So here it is! The script checks the returned data against previously received data, and increases the time between calls if it hasn&#8217;t changed.</p>
<p>I&#8217;d be interested in your comments. Would it be useful to turn this into a plugin?</p>
<p><a href="http://johnmccollum.co.uk/decay">View the demonstration here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/converting-prototypes-ajaxperiodicalupdater-to-jquery/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Using JSON to access the Twitter search API</title>
		<link>http://johnmc.co/llum/using-json-to-access-the-twitter-search-api/</link>
		<comments>http://johnmc.co/llum/using-json-to-access-the-twitter-search-api/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 09:35:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=81</guid>
		<description><![CDATA[Steve Reynolds recently wrote a blog post showing how to access the twitter search API using PHP, cURL, and JQuery. Steve used JQuery to post to a page on his server, which then cURLed in search results for a given term. This approach is often necessary to get avoid the issue of cross domain ajax [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fusing-json-to-access-the-twitter-search-api%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fusing-json-to-access-the-twitter-search-api%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.reynoldsftw.com/">Steve Reynolds</a> recently wrote a blog post showing <a href="http://www.reynoldsftw.com/2009/02/using-jquery-php-ajax-with-the-twitter-api/">how to access the twitter search API using PHP, cURL, and JQuery</a>.</p>
<p>Steve used JQuery to post to a page on his server, which then cURLed in search results for a given term. This approach is often necessary to get avoid the issue of cross domain ajax calls.</p>
<p>While this approach works well, there&#8217;s an even easier way to go about it &#8211; $.getJSON!</p>
<p>There are two main advantages to this approach:</p>
<ul>
<li>Server side technology isn&#8217;t an issue. You don&#8217;t have to rely on PHP, cURL, firewalls, anything like that. It will even work on a static HTML page!</li>
<li>All the work is done on the client&#8217;s browser &#8211; saving precious bandwidth! This could be important on busy sites.</li>
</ul>
<p>I&#8217;ve knocked up a quick-and-dirty demonstration of this concept. If a name doesn&#8217;t already exist for this methodology, my vote goes for JAJA (Javascript and JSON, asynchronous!)</p>
<p><a href="http://johnmccollum.co.uk/twitterjson/">View the demonstration here!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/using-json-to-access-the-twitter-search-api/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>How to build search into your site with JQuery and Yahoo!</title>
		<link>http://johnmc.co/llum/how-to-build-search-into-your-site-with-jquery-and-yahoo/</link>
		<comments>http://johnmc.co/llum/how-to-build-search-into-your-site-with-jquery-and-yahoo/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 21:06:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[Yahoo]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=36</guid>
		<description><![CDATA[Yahoo have a hard time fighting off the image of being bridesmaid to Google&#8217;s bride. However, they have a decided knack for turning out really cool developer toys! For example, check out the Yahoo User Interface library, Yahoo Pipes, or their latest baby, Yahoo BOSS. Short for &#8216;Build your Own Search Service&#8217;, Yahoo have pretty [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fhow-to-build-search-into-your-site-with-jquery-and-yahoo%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fhow-to-build-search-into-your-site-with-jquery-and-yahoo%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Yahoo have a hard time fighting off the image of being bridesmaid to Google&#8217;s bride. However, they have a decided knack for turning out really cool developer toys! For example, check out the <a href="http://developer.yahoo.com/yui/">Yahoo User Interface library</a>, <a href="http://pipes.yahoo.com/pipes/">Yahoo Pipes</a>, or their latest baby, <a href="http://developer.yahoo.com/search/boss/">Yahoo BOSS</a>.</p>
<p>Short for &#8216;Build your Own Search Service&#8217;, Yahoo have pretty much opened up their entire search service via an API. With an unrestricted number of queries, and complete control over presentation of results, you can really go to town with this one!</p>
<p>Getting started is easy; simply get yourself an <a href="http://developer.yahoo.com/wsregapp/">API key here</a>. Go on, I&#8217;ll wait.</p>
<p>With that done, anyone with basic knowledge of <a href="http://johnmccollum.co.uk/category/php/">PHP</a> and <a href="http://johnmccollum.co.uk/category/jquery/">JQuery</a> can easily build a search application!</p>
<p><a href="http://johnmccollum.co.uk/boss/">Check out my demonstration here.</a></p>
<p>There are two pages involved in this demonstration. The first page displays the form, and contains the necessary JQuery code to fire off an AJAX request to the second page. The second page takes the posted value, fires off a request to the API, and returns the result.</p>
<p>Without further ado, here&#8217;s the JQuery:<br />
<pre><pre>&nbsp;&nbsp;&nbsp;&nbsp;$(document).ready(function(){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&#039;#results&#039;).hide();

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&#039;#search&#039;).click(function(){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&#039;#results&#039;).hide();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;searchterm = $(&#039;#searchterm&#039;).val();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$.post(&#039;getresult.php&#039;, {query: searchterm}, function(data){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&#039;#results&#039;).html(data).show(&#039;slow&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;})
&nbsp;&nbsp;&nbsp;&nbsp;})</pre></pre><br />
Nothing too horrendous here; hide the results division, grab the term to be searched for, fire off an AJAX request, and put the returned data in the results div. Show it slloooooowly. <img src='http://johnmc.co/llum/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The code in &#8216;getresult.php&#8217; isn&#8217;t much more complex; <a href="http://johnmccollum.co.uk/boss/getresult.txt">you can see it here.</a></p>
<p>That&#8217;s all there is to it! (At least for this very basic example.)</p>
<p>Once again, <a href="http://johnmccollum.co.uk/boss/">you can see a demonstration here</a>.</p>
<p>I&#8217;m sure there must be loads of ideas for mashups out there; let&#8217;s hear some of your thoughts!</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/how-to-build-search-into-your-site-with-jquery-and-yahoo/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Simple Jquery and CSS menu</title>
		<link>http://johnmc.co/llum/simple-jquery-and-css-menu/</link>
		<comments>http://johnmc.co/llum/simple-jquery-and-css-menu/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 09:57:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Menu]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=18</guid>
		<description><![CDATA[I&#8217;ve had some fun this weekend tinkering with Jquery. It&#8217;s taken me a long time to get round to playing with this library, having thrown my eggs in the Prototype / Scriptaculous basket, but after some experimentation, I wish I&#8217;d done it sooner! I have to admit; the syntax is nicer, much simpler (no more [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fsimple-jquery-and-css-menu%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fsimple-jquery-and-css-menu%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve had some fun this weekend tinkering with <a href="http://jquery.com">Jquery</a>. It&#8217;s taken me a long time to get round to playing with this library, having thrown my eggs in the <a href="http://prototype.org">Prototype</a> / <a href="http://script.aculo.us">Scriptaculous</a> basket, but after some experimentation, I wish I&#8217;d done it sooner!</p>
<p>I have to admit; the syntax is nicer, much simpler (no more $$(&#8216;selector&#8217;)) and the documentation seems better. Jquery is also lightweight and fast.</p>
<p>To celebrate my switchover, here&#8217;s a very simple <a href="http://johnmccollum.co.uk/jquerymenu.html">Jquery menu demonstration</a>!</p>
<p>Let&#8217;s start off with the HTML:<br />
<pre><pre>
&lt;div id=&quot;”content”&quot;&gt;
&lt;ul id=&quot;”menu”&quot;&gt;
&nbsp;&nbsp;&lt;li class=&quot;”starter”&amp;gt;menu&quot;&gt;&lt;/li&gt;
&nbsp;&nbsp;&lt;li&gt;&lt;a href=&quot;”#”&quot;&gt;home&lt;/a&gt;&lt;/li&gt;
&nbsp;&nbsp;&lt;li&gt;&lt;a href=&quot;”#”&quot;&gt;about us&lt;/a&gt;&lt;/li&gt;
&nbsp;&nbsp;&lt;li&gt;a href=”#”&amp;gt;portfolio&lt;/li&gt;
&nbsp;&nbsp;&lt;li&gt;&lt;a href=&quot;”#”&quot;&gt;contact us&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</pre></pre><br />
It doesn&#8217;t get much simpler than this! An ordered list, ready for styling. Not much to see here. Here comes the javascript:<br />
<pre><pre>$(document).ready(function(){
&nbsp;&nbsp;$(&quot;li:not(:first)&quot;).hide();

&nbsp;&nbsp;$(&quot;li.starter&quot;).click(function(){
&nbsp;&nbsp;&nbsp;&nbsp;if($(&quot;li:not(:first)&quot;).is(&quot;:visible&quot;)){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;li:not(:first)&quot;).fadeOut(&quot;fast&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;}else{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;li:not(:first)&quot;).fadeIn(&quot;fast&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;})
})</pre></pre><br />
Eek! Slightly more complicated. Let&#8217;s walk through it.<br />
<pre>$(document).ready(function(){</pre><br />
Before we do anything, we make sure that the DOM is ready for manipulation. This has a handy side effect, when we see the next line:<br />
<pre>$(&quot;li:not(:first)&quot;).hide();</pre><br />
This piece of code looks for all the &#8216;li&#8217; elements in the page (disregarding the first one) and hides them, using display:none. The great thing is, since we&#8217;re doing this within $(document).ready, users with javascript switched off will still see the menu!<br />
<pre>$(&quot;li.starter&quot;).click(function(){</pre><br />
This tells the browser to look out for any clicks on the li.starter element, and use the next bit of code to handle it.<br />
<pre><pre>if($(&quot;li:not(:first)&quot;).is(&quot;:visible&quot;)){
&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;li:not(:first)&quot;).fadeOut(&quot;fast&quot;);
}else{
&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;li:not(:first)&quot;).fadeIn(&quot;fast&quot;);
}</pre></pre><br />
This part checks to see if the list items are visible, and shows them or hides them as appropriate.</p>
<p>You can see the full <a href="http://johnmccollum.co.uk/jquerymenu.html">demonstration here</a>, with comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/simple-jquery-and-css-menu/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

