<?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>Perplexed Labs &#187; JavaScript</title>
	<atom:link href="http://blog.perplexedlabs.com/category/development/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.perplexedlabs.com</link>
	<description>web development war stories from the frontlines to the backend</description>
	<lastBuildDate>Mon, 16 May 2011 14:19:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>jQuery 1.4.2 Released</title>
		<link>http://blog.perplexedlabs.com/2010/02/20/jquery-1-4-2-released/</link>
		<comments>http://blog.perplexedlabs.com/2010/02/20/jquery-1-4-2-released/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 17:56:56 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://blog.perplexedlabs.com/?p=421</guid>
		<description><![CDATA[Just a quick note alerting everyone to the fact that jQuery has gotten EVEN EASIER AND FASTER. Go check out the release notes. Related posts:jQuery 1.4 Released jQuery 1.3.1 Go For Launch jQuery 1.4 Alpha 1 Released


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2010/01/14/jquery-1-4-released/' rel='bookmark' title='Permanent Link: jQuery 1.4 Released'>jQuery 1.4 Released</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/01/24/jquery-131-go-for-launch/' rel='bookmark' title='Permanent Link: jQuery 1.3.1 Go For Launch'>jQuery 1.3.1 Go For Launch</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/12/05/jquery-1-4-alpha-1-released/' rel='bookmark' title='Permanent Link: jQuery 1.4 Alpha 1 Released'>jQuery 1.4 Alpha 1 Released</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Just a quick note alerting everyone to the fact that jQuery has gotten EVEN EASIER AND FASTER.</p>
<p>Go check out the <a href="http://blog.jquery.com/2010/02/19/jquery-142-released/">release notes</a>.</p>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2010/01/14/jquery-1-4-released/' rel='bookmark' title='Permanent Link: jQuery 1.4 Released'>jQuery 1.4 Released</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/01/24/jquery-131-go-for-launch/' rel='bookmark' title='Permanent Link: jQuery 1.3.1 Go For Launch'>jQuery 1.3.1 Go For Launch</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/12/05/jquery-1-4-alpha-1-released/' rel='bookmark' title='Permanent Link: jQuery 1.4 Alpha 1 Released'>jQuery 1.4 Alpha 1 Released</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2010/02/20/jquery-1-4-2-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery 1.4 Released</title>
		<link>http://blog.perplexedlabs.com/2010/01/14/jquery-1-4-released/</link>
		<comments>http://blog.perplexedlabs.com/2010/01/14/jquery-1-4-released/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 20:57:24 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.perplexedlabs.com/?p=405</guid>
		<description><![CDATA[Many (awesome) changes http://blog.jquery.com/2010/01/14/jquery-14-released/. View the release notes here: http://jquery14.com/day-01/jquery-14 Related posts:jQuery 1.4.2 Released jQuery 1.4 Alpha 1 Released jQuery 1.4a2 (Alpha 2) Released


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2010/02/20/jquery-1-4-2-released/' rel='bookmark' title='Permanent Link: jQuery 1.4.2 Released'>jQuery 1.4.2 Released</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/12/05/jquery-1-4-alpha-1-released/' rel='bookmark' title='Permanent Link: jQuery 1.4 Alpha 1 Released'>jQuery 1.4 Alpha 1 Released</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/12/19/jquery-1-4a2-alpha-2-released/' rel='bookmark' title='Permanent Link: jQuery 1.4a2 (Alpha 2) Released'>jQuery 1.4a2 (Alpha 2) Released</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Many (awesome) changes <a href="http://blog.jquery.com/2010/01/14/jquery-14-released/">http://blog.jquery.com/2010/01/14/jquery-14-released/</a>.</p>
<p>View the release notes here: <a href="http://jquery14.com/day-01/jquery-14">http://jquery14.com/day-01/jquery-14</a></p>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2010/02/20/jquery-1-4-2-released/' rel='bookmark' title='Permanent Link: jQuery 1.4.2 Released'>jQuery 1.4.2 Released</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/12/05/jquery-1-4-alpha-1-released/' rel='bookmark' title='Permanent Link: jQuery 1.4 Alpha 1 Released'>jQuery 1.4 Alpha 1 Released</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/12/19/jquery-1-4a2-alpha-2-released/' rel='bookmark' title='Permanent Link: jQuery 1.4a2 (Alpha 2) Released'>jQuery 1.4a2 (Alpha 2) Released</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2010/01/14/jquery-1-4-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery 1.4a2 (Alpha 2) Released</title>
		<link>http://blog.perplexedlabs.com/2009/12/19/jquery-1-4a2-alpha-2-released/</link>
		<comments>http://blog.perplexedlabs.com/2009/12/19/jquery-1-4a2-alpha-2-released/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 16:04:28 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[1.4]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery 1.4]]></category>

		<guid isPermaLink="false">http://blog.perplexedlabs.com/?p=400</guid>
		<description><![CDATA[The wonderful folks over at jQuery have released Alpha 2 of version 1.4 for all those testers out there. 1.4 is slated for official launch on January 14th - how cute :) Related posts:jQuery 1.4 Alpha 1 Released jQuery 1.3 Beta Testing jQuery 1.4.2 Released


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2009/12/05/jquery-1-4-alpha-1-released/' rel='bookmark' title='Permanent Link: jQuery 1.4 Alpha 1 Released'>jQuery 1.4 Alpha 1 Released</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/12/22/jquery-13-beta-testing/' rel='bookmark' title='Permanent Link: jQuery 1.3 Beta Testing'>jQuery 1.3 Beta Testing</a></li>
<li><a href='http://blog.perplexedlabs.com/2010/02/20/jquery-1-4-2-released/' rel='bookmark' title='Permanent Link: jQuery 1.4.2 Released'>jQuery 1.4.2 Released</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The wonderful folks over at jQuery have released <a href="http://blog.jquery.com/2009/12/18/jquery-14-alpha-2-released/">Alpha 2</a> of version 1.4 for all those testers out there.</p>
<p>1.4 is slated for official launch on January 14th - how cute :)</p>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2009/12/05/jquery-1-4-alpha-1-released/' rel='bookmark' title='Permanent Link: jQuery 1.4 Alpha 1 Released'>jQuery 1.4 Alpha 1 Released</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/12/22/jquery-13-beta-testing/' rel='bookmark' title='Permanent Link: jQuery 1.3 Beta Testing'>jQuery 1.3 Beta Testing</a></li>
<li><a href='http://blog.perplexedlabs.com/2010/02/20/jquery-1-4-2-released/' rel='bookmark' title='Permanent Link: jQuery 1.4.2 Released'>jQuery 1.4.2 Released</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2009/12/19/jquery-1-4a2-alpha-2-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery 1.4 Alpha 1 Released</title>
		<link>http://blog.perplexedlabs.com/2009/12/05/jquery-1-4-alpha-1-released/</link>
		<comments>http://blog.perplexedlabs.com/2009/12/05/jquery-1-4-alpha-1-released/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 16:57:23 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://blog.perplexedlabs.com/?p=398</guid>
		<description><![CDATA[Just wanted to mention that jQuery 1.4 Alpha 1 has been released. Most of the changes seem to revolve around heavy optimization of some core functionality. Installing this alpha and testing in live applications will help get this release out! Related posts:jQuery 1.4a2 (Alpha 2) Released jQuery 1.4.2 Released jQuery 1.4 Released


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2009/12/19/jquery-1-4a2-alpha-2-released/' rel='bookmark' title='Permanent Link: jQuery 1.4a2 (Alpha 2) Released'>jQuery 1.4a2 (Alpha 2) Released</a></li>
<li><a href='http://blog.perplexedlabs.com/2010/02/20/jquery-1-4-2-released/' rel='bookmark' title='Permanent Link: jQuery 1.4.2 Released'>jQuery 1.4.2 Released</a></li>
<li><a href='http://blog.perplexedlabs.com/2010/01/14/jquery-1-4-released/' rel='bookmark' title='Permanent Link: jQuery 1.4 Released'>jQuery 1.4 Released</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Just wanted to mention that <a href="http://blog.jquery.com/2009/12/04/jquery-14-alpha-1-released/">jQuery 1.4 Alpha 1</a> has been released.</p>
<p>Most of the changes seem to revolve around heavy optimization of some core functionality.  Installing this alpha and testing in live applications will help get this release out!</p>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2009/12/19/jquery-1-4a2-alpha-2-released/' rel='bookmark' title='Permanent Link: jQuery 1.4a2 (Alpha 2) Released'>jQuery 1.4a2 (Alpha 2) Released</a></li>
<li><a href='http://blog.perplexedlabs.com/2010/02/20/jquery-1-4-2-released/' rel='bookmark' title='Permanent Link: jQuery 1.4.2 Released'>jQuery 1.4.2 Released</a></li>
<li><a href='http://blog.perplexedlabs.com/2010/01/14/jquery-1-4-released/' rel='bookmark' title='Permanent Link: jQuery 1.4 Released'>jQuery 1.4 Released</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2009/12/05/jquery-1-4-alpha-1-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>8 Books To Get A Developer For The Holidays</title>
		<link>http://blog.perplexedlabs.com/2009/11/30/8-books-to-get-a-developer-for-the-holidays/</link>
		<comments>http://blog.perplexedlabs.com/2009/11/30/8-books-to-get-a-developer-for-the-holidays/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 13:30:06 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Book Reviews]]></category>
		<category><![CDATA[Clojure]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[book review]]></category>
		<category><![CDATA[clojure]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programmer]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.perplexedlabs.com/?p=385</guid>
		<description><![CDATA[Send this to your significant other/parent/relative/friend so, instead of that sweater, you get one of these nuggets of awesome this Christmas. The Pragmatic Programmer: From Journeyman to Master Write better, cleaner, more maintainable code. Learn how to manage your projects and focus on shipping your product. With insight that covers the gamut of software development [...]


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2009/06/01/be-language-agnostic-solve-the-problem/' rel='bookmark' title='Permanent Link: Be Language Agnostic &#8211; Solve the Problem!'>Be Language Agnostic &#8211; Solve the Problem!</a></li>
<li><a href='http://blog.perplexedlabs.com/2010/02/08/deployment-using-capistrano-and-webistrano-via-rails-and-phusion-passenger/' rel='bookmark' title='Permanent Link: Deployment Using Capistrano / Webistrano via Rails / Phusion Passenger'>Deployment Using Capistrano / Webistrano via Rails / Phusion Passenger</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/07/28/django-1-0-template-development-sample-chapter-serving-multiple-templates/' rel='bookmark' title='Permanent Link: Django 1.0 Template Development: Sample Chapter &#8220;Serving Multiple Templates&#8221;'>Django 1.0 Template Development: Sample Chapter &#8220;Serving Multiple Templates&#8221;</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Send this to your significant other/parent/relative/friend so, instead of that sweater, you get one of these nuggets of awesome this Christmas.</p>
<h3><a href="http://www.amazon.com/gp/product/020161622X?ie=UTF8&#038;tag=perplabs-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=020161622X">The Pragmatic Programmer: From Journeyman to Master</a><img src="http://www.assoc-amazon.com/e/ir?t=perplabs-20&#038;l=as2&#038;o=1&#038;a=020161622X" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></h3>
<p>Write better, cleaner, more maintainable code.  Learn how to manage your projects and focus on shipping your product.  With insight that covers the gamut of software development from low level to management<br />
this one is a must have for anyone involved in this industry.</p>
<h3><a href="http://www.amazon.com/gp/product/1934356344?ie=UTF8&#038;tag=perplabs-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1934356344">The Passionate Programmer: Creating a Remarkable Career in Software Development</a><img src="http://www.assoc-amazon.com/e/ir?t=perplabs-20&#038;l=as2&#038;o=1&#038;a=1934356344" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></h3>
<p>Highly recommended!  <a href="http://blog.perplexedlabs.com/2009/07/29/book-review-the-passionate-programmer/">Read my full review</a>.</p>
<h3><a href="http://www.amazon.com/gp/product/0735619670?ie=UTF8&#038;tag=perplabs-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0735619670">Code Complete: A Practical Handbook of Software Construction</a><img src="http://www.assoc-amazon.com/e/ir?t=perplabs-20&#038;l=as2&#038;o=1&#038;a=0735619670" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></h3>
<p>Another classic "software construction" book.  Sharpen your saw with timeless information that can be applied to any project in any language.  Less bugs, more productivity, more programmer happiness.</p>
<h3><a href="http://www.amazon.com/gp/product/1430219483?ie=UTF8&#038;tag=perplabs-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1430219483">Coders at Work</a><img src="http://www.assoc-amazon.com/e/ir?t=perplabs-20&#038;l=as2&#038;o=1&#038;a=1430219483" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></h3>
<p>This one is different.  Written as a set of interview transcripts with 15 legendary industry giants, this book is a fantastic insight into how some of the great minds think.  It's inspiring to hear it from the source, must have!</p>
<h3><a href="http://www.amazon.com/gp/product/1934356336?ie=UTF8&#038;tag=perplabs-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1934356336">Programming Clojure</a><img src="http://www.assoc-amazon.com/e/ir?t=perplabs-20&#038;l=as2&#038;o=1&#038;a=1934356336" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></h3>
<p>A developer should learn at least one new language a year.  This year that language should be Clojure.  Clojure is a dynamic, general purpose, language targeting the Java virtual machine and designed for multi-threaded use.  It's growing popularity, ability to leverage the Java standard library, and its multi-threaded nature make this a must have.</p>
<h3><a href="http://www.amazon.com/gp/product/0201835959?ie=UTF8&#038;tag=perplabs-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0201835959">The Mythical Man-Month: Essays on Software Engineering</a><img src="http://www.assoc-amazon.com/e/ir?t=perplabs-20&#038;l=as2&#038;o=1&#038;a=0201835959" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></h3>
<p>Another classic.  Primarily discusses project management from the perspective of Fred Brooks and his experiences at IBM.  Brooks' Law states that "adding manpower to a late software project makes it later".</p>
<h3><a href="http://www.amazon.com/gp/product/0321344758?ie=UTF8&#038;tag=perplabs-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0321344758">Don't Make Me Think: A Common Sense Approach to Web Usability</a><img src="http://www.assoc-amazon.com/e/ir?t=perplabs-20&#038;l=as2&#038;o=1&#038;a=0321344758" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></h3>
<p>Web developers should always keep in mind the user of the product their creating.  Usability becomes increasingly important as applications move to the web.  The design and usability of your app can make or break its success.  This classic is a must read.</p>
<h3><a href="http://www.amazon.com/gp/product/0201633612?ie=UTF8&#038;tag=perplabs-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0201633612">Design Patterns: Elements of Reusable Object-Oriented Software</a><img src="http://www.assoc-amazon.com/e/ir?t=perplabs-20&#038;l=as2&#038;o=1&#038;a=0201633612" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></h3>
<p>This classic known most commonly as the "gang of four" book is the definitive reference on design patterns.  Covering all of the most common cases and time and time again serving as an invaluable source of information.</p>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2009/06/01/be-language-agnostic-solve-the-problem/' rel='bookmark' title='Permanent Link: Be Language Agnostic &#8211; Solve the Problem!'>Be Language Agnostic &#8211; Solve the Problem!</a></li>
<li><a href='http://blog.perplexedlabs.com/2010/02/08/deployment-using-capistrano-and-webistrano-via-rails-and-phusion-passenger/' rel='bookmark' title='Permanent Link: Deployment Using Capistrano / Webistrano via Rails / Phusion Passenger'>Deployment Using Capistrano / Webistrano via Rails / Phusion Passenger</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/07/28/django-1-0-template-development-sample-chapter-serving-multiple-templates/' rel='bookmark' title='Permanent Link: Django 1.0 Template Development: Sample Chapter &#8220;Serving Multiple Templates&#8221;'>Django 1.0 Template Development: Sample Chapter &#8220;Serving Multiple Templates&#8221;</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2009/11/30/8-books-to-get-a-developer-for-the-holidays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP jQuery AJAX Javascript Long Polling</title>
		<link>http://blog.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/</link>
		<comments>http://blog.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comments</comments>
		<pubDate>Mon, 04 May 2009 14:00:14 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[long polling]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=217</guid>
		<description><![CDATA[Background "Long polling" is the name used to describe a technique which: An AJAX request is made (utilizing a javascript framework such as jQuery) The server waits for the data requested to be available, loops, and sleeps (your server-side PHP script) This loop repeats after data is returned to the client and processed (usually in [...]


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2008/11/07/real-time-ajax-javascript-progress-bar/' rel='bookmark' title='Permanent Link: Real-time &#8220;AJAX&#8221; JavaScript Progress Bar'>Real-time &#8220;AJAX&#8221; JavaScript Progress Bar</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/02/05/dynamic-javascript-script-insertion-for-embedding/' rel='bookmark' title='Permanent Link: PHP Dynamic JavaScript SCRIPT Insertion for Embedding'>PHP Dynamic JavaScript SCRIPT Insertion for Embedding</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/02/12/php-fast-large-megabyte-data-transfer-between-sessions/' rel='bookmark' title='Permanent Link: PHP fast, large (megabyte), data transfer between sessions'>PHP fast, large (megabyte), data transfer between sessions</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h3>Background</h3>
<p>"Long polling" is the name used to describe a technique which:</p>
<ul>
<li>An AJAX request is made (utilizing a javascript framework such as jQuery)
<li>The server waits for the data requested to be available, loops, and sleeps (your server-side PHP script)
<li>This loop repeats after data is returned to the client and processed (usually in your AJAX request's onComplete callback function)
</ul>
<p>This essentially simulates a continuous real-time stream from the client to the server.  It can be more efficient than a regular polling technique because of the reduction in HTTP requests.  You're not asking over and over and over again for new data - you ask once and wait for an answer.  In most cases this reduces the latency in which data becomes available to your application.</p>
<p>There are a variety of use cases in which this technique can be handy.  At the top of the list are real-time web-based chat applications.  Each client executes a long polling loop for chat and user events (sign on/sign off/new message).  <a href="http://www.meebo.com">Meebo</a> is perhaps the greatest example of this.</p>
<p>It's important to note some of the server side technical limitations of long polling.  Because connections remain open for considerably longer time than a typical HTTP request/response cycle you want your web server to be able to handle a large number of simultaneous connections.  Apache isn't the best candidate for this type of situation.  <a href="http://nginx.net/">nginx</a> and <a href="http://www.lighttpd.net/">lighttpd</a> are two lightweight web servers built from the ground up to handle a high volume of simultaneous connections.  Both support the FastCGI interface and as such can be configured to support PHP.  Again, Meebo uses lighttpd.</p>
<p>For similar reasons - it's also a good idea to choose a different sub-domain to handle long polling traffic.  Because of client side browser limitations you don't want long polling connections interfering with regular HTTP traffic delivering page and media resources for your application.</p>
<h3>Implementation</h3>
<p><a href="http://www.jquery.com">jQuery</a> makes implementation a breeze.</p>
<pre class="brush: jscript; title: ;">
var lpOnComplete = function(response) {
	alert(response);
	// do more processing
	lpStart();
};

var lpStart = function() {
	$.post('/path/to/script', {}, lpOnComplete, 'json');
};

$(document).ready(lpStart);
</pre>
<p>Straightforward.  When the document is ready the loop begins.  Each iteration the returned data is processed and the loop is restarted.</p>
<p>On the server side - just like we discussed earlier:</p>
<pre class="brush: php; title: ;">
$time = time();
while((time() - $time) &lt; 30) {
	// query memcache, database, etc. for new data
	$data = $datasource-&gt;getLatest();

	// if we have new data return it
	if(!empty($data)) {
		echo json_encode($data);
		break;
	}

	usleep(25000);
}
</pre>
<p>Actually, a couple points of interest here.  We don't actually loop <em>infinitely</em> server side.  You may have noticed the logic for the while loop - if we've executed for more than 30 seconds we discontinue the loop and return nothing.  This nearly eliminates the possibility of substantial memory leaks.  Also, if we didn't put a cap on execution time we would need to print a "space" character and flush output buffers every iteration of the loop to keep PHP abreast to the status of this process/connection.  <strong>Without output being sent PHP cannot determine if the connection was lost via connection_status() or connection_aborted()</strong>.  As a result this could lead to a situation where there are an increasing number of "ghost" processes eating up server resources.  Not good!</p>
<p>That pretty much sums it up!  Not that difficult, right?</p>
<p>As always, questions/comments are welcome, hope this helps!</p>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2008/11/07/real-time-ajax-javascript-progress-bar/' rel='bookmark' title='Permanent Link: Real-time &#8220;AJAX&#8221; JavaScript Progress Bar'>Real-time &#8220;AJAX&#8221; JavaScript Progress Bar</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/02/05/dynamic-javascript-script-insertion-for-embedding/' rel='bookmark' title='Permanent Link: PHP Dynamic JavaScript SCRIPT Insertion for Embedding'>PHP Dynamic JavaScript SCRIPT Insertion for Embedding</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/02/12/php-fast-large-megabyte-data-transfer-between-sessions/' rel='bookmark' title='Permanent Link: PHP fast, large (megabyte), data transfer between sessions'>PHP fast, large (megabyte), data transfer between sessions</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>JavaScript roundTo Nearest Thousandth, Hundredth, Tenth, *</title>
		<link>http://blog.perplexedlabs.com/2009/02/06/javascript-roundto-nearest-thousandth-hundredth-tenth/</link>
		<comments>http://blog.perplexedlabs.com/2009/02/06/javascript-roundto-nearest-thousandth-hundredth-tenth/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 18:53:42 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[round]]></category>
		<category><![CDATA[rounding]]></category>

		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=153</guid>
		<description><![CDATA[This very simple function does exactly what the title suggests, it allows you to round to any specified accuracy. function roundTo(number, to) { return Math.round(number * to) / to; } alert(roundTo(1532, 100)); // 1500 alert(roundTo(26, 10)); // 30 If you want to get fancy, you could also modify the Number prototype for a more "integrated" [...]


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2008/11/12/javascript-event-handler/' rel='bookmark' title='Permanent Link: JavaScript Event Handler'>JavaScript Event Handler</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/11/07/real-time-ajax-javascript-progress-bar/' rel='bookmark' title='Permanent Link: Real-time &#8220;AJAX&#8221; JavaScript Progress Bar'>Real-time &#8220;AJAX&#8221; JavaScript Progress Bar</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/' rel='bookmark' title='Permanent Link: PHP jQuery AJAX Javascript Long Polling'>PHP jQuery AJAX Javascript Long Polling</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This very simple function does exactly what the title suggests, it allows you to round to any specified accuracy.</p>
<pre class="brush: jscript; title: ;">
function roundTo(number, to) {
	return Math.round(number * to) / to;
}

alert(roundTo(1532, 100)); // 1500
alert(roundTo(26, 10)); // 30
</pre>
<p>If you want to get fancy, you could also modify the Number prototype for a more "integrated" solution.</p>
<pre class="brush: jscript; title: ;">
Number.prototype.roundTo = function(to) {
	return Math.round(this * to) / to;
}
</pre>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2008/11/12/javascript-event-handler/' rel='bookmark' title='Permanent Link: JavaScript Event Handler'>JavaScript Event Handler</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/11/07/real-time-ajax-javascript-progress-bar/' rel='bookmark' title='Permanent Link: Real-time &#8220;AJAX&#8221; JavaScript Progress Bar'>Real-time &#8220;AJAX&#8221; JavaScript Progress Bar</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/' rel='bookmark' title='Permanent Link: PHP jQuery AJAX Javascript Long Polling'>PHP jQuery AJAX Javascript Long Polling</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2009/02/06/javascript-roundto-nearest-thousandth-hundredth-tenth/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Dynamic JavaScript SCRIPT Insertion for Embedding</title>
		<link>http://blog.perplexedlabs.com/2009/02/05/dynamic-javascript-script-insertion-for-embedding/</link>
		<comments>http://blog.perplexedlabs.com/2009/02/05/dynamic-javascript-script-insertion-for-embedding/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 20:21:34 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[SCRIPT]]></category>

		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=136</guid>
		<description><![CDATA[For an internal project I've been working on I have to provide embeddable versions of internal tools for deployment on remote partner sites. I achieved this in my framework through, what I call, output format filters. Let's say you have an action "cloud" in a controller "markets". The URL to access this resource in its [...]


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/' rel='bookmark' title='Permanent Link: PHP jQuery AJAX Javascript Long Polling'>PHP jQuery AJAX Javascript Long Polling</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/11/07/real-time-ajax-javascript-progress-bar/' rel='bookmark' title='Permanent Link: Real-time &#8220;AJAX&#8221; JavaScript Progress Bar'>Real-time &#8220;AJAX&#8221; JavaScript Progress Bar</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/02/06/javascript-roundto-nearest-thousandth-hundredth-tenth/' rel='bookmark' title='Permanent Link: JavaScript roundTo Nearest Thousandth, Hundredth, Tenth, *'>JavaScript roundTo Nearest Thousandth, Hundredth, Tenth, *</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>For an internal project I've been working on I have to provide embeddable versions of internal tools for deployment on remote partner sites.</p>
<p>I achieved this in my framework through, what I call, output format filters.  Let's say you have an action "cloud" in a controller "markets".  The URL to access this resource in its full glory would be:</p>
<blockquote>
<p>http://www.domainname.com/markets/cloud</p>
</blockquote>
<p>Pretty standard stuff.  Let's say we want to offer an embeddable version of this resource.  I can append an "output format filter" on this resource:</p>
<blockquote>
<p>http://www.domainname.com/markets/cloud/embed</p>
</blockquote>
<p>Alright, again, pretty standard stuff.  How on earth does this relate to dynamic javascript SCRIPT insertion?</p>
<p>On the remote partner site, I ask them to place the following HTML fragment in the desired location they want the resource to appear:</p>
<pre class="brush: xml; title: ;">
&lt;script language=&quot;javascript&quot; type=&quot;text/javscript&quot; src=&quot;http://www.domainname.com/markets/cloud/embed&quot;&gt;&lt;/script&gt;
</pre>
<p>One line of HTML.</p>
<p>How does this work under the hood?  It simply takes the view's content and prepares it as a valid javascript document.write.  It also specifies certain HTML headers, notably:</p>
<blockquote><p><strong>Content-Type: application/x-javascript</strong></p></blockquote>
<pre class="brush: php; title: ;">
function prepJS($js)
{
	// prepare the output as valid javascript
	$js = str_replace(&quot;\\&quot;, &quot;\\\\&quot;, $js);
	$js = preg_replace(&quot;/[\r\n]+/&quot;, '\n', $js);
	$js = str_replace('&quot;', '\&quot;', $js);
	$js = preg_replace(&quot;/&lt;script/i&quot;, '&lt;scr&quot;+&quot;ipt', $js);
	$js = preg_replace(&quot;/&lt;\/script/i&quot;, '&lt;/scr&quot;+&quot;ipt', $js);

	return $js;
}
</pre>
<pre class="brush: jscript; title: ;">
document.write(&quot;&lt;?php echo prepJS($viewContent); ?&gt;&quot;);
</pre>
<p>It should be fairly obvious what the function does.  It escapes double quotes, adds slashes, and replaces newlines and carriage returns with their inline equivalent.  Additionally and VERY important, it splits SCRIPT tag elements (if your view had inline SCRIPT's) into SCR"+"IPT so that the browser treats these as pure strings and doesn't cause JavaScript parsing errors.</p>
<p>What if the resource you are embedding depends upon the availability of certain JavaScript libraries or external source files?  The first response usually is, myself included, to simply document.write more SCRIPT tags!</p>
<pre class="brush: jscript; title: ;">
document.write(&quot;
&lt;?php prepJS('&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;http://www.domainname.com/path/to/jquery.js&quot;&gt;&lt;/script&gt;'); ?&gt;
&quot;);
document.write(&quot;
&lt;?php prepJS('&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;http://www.domainname.com/path/to/morejs.js&quot;&gt;&lt;/script&gt;'); ?&gt;
&quot;);
document.write(&quot;&lt;?php echo prepJS($viewContent); ?&gt;&quot;);
</pre>
<p>The problem is of course that in IE, <a href="http://stackoverflow.com/questions/94141/javascripts-document-write-inline-script-execution-order">there's no telling what order those SCRIPT tags will get executed</a>.  Furthermore, if your resource depends on them, they need to be executed <strong>before</strong> you document.write the content.</p>
<p>My solution to this problem was two-fold.  For other reasons not worth going into here, it's generally a good idea to concatenate all your JavaScript source files into one larger file, minify (if desired), cache, and serve the result.  Taking advantage of this we can reduce the above to a single additional SCRIPT insertion.  Tack this snippet onto the end of that file:</p>
<pre class="brush: jscript; title: ;">
if(typeof(embedReady) != 'undefined') {
	embedReady();
}
</pre>
<p>And we come up with this:</p>
<pre class="brush: jscript; title: ;">
document.write(&quot;
&lt;?php prepJS('&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;http://www.domainname.com/path/to/cached_combined_js.js&quot;&gt;&lt;/script&gt;'); ?&gt;
&quot;);
var embedReady = function() {
    document.write(&quot;&lt;?php echo prepJS($viewContent); ?&gt;&quot;);
}
</pre>
<p>Now we're only concerned with a single SCRIPT load.  We've safely placed our document.write of content inside a function that's called at the end of our dependency SCRIPT.  In an elegant, browser agnostic fashion our resource will have it's dependencies loaded before it executes.</p>
<p>Yay?</p>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/' rel='bookmark' title='Permanent Link: PHP jQuery AJAX Javascript Long Polling'>PHP jQuery AJAX Javascript Long Polling</a></li>
<li><a href='http://blog.perplexedlabs.com/2008/11/07/real-time-ajax-javascript-progress-bar/' rel='bookmark' title='Permanent Link: Real-time &#8220;AJAX&#8221; JavaScript Progress Bar'>Real-time &#8220;AJAX&#8221; JavaScript Progress Bar</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/02/06/javascript-roundto-nearest-thousandth-hundredth-tenth/' rel='bookmark' title='Permanent Link: JavaScript roundTo Nearest Thousandth, Hundredth, Tenth, *'>JavaScript roundTo Nearest Thousandth, Hundredth, Tenth, *</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2009/02/05/dynamic-javascript-script-insertion-for-embedding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery 1.3.1 Go For Launch</title>
		<link>http://blog.perplexedlabs.com/2009/01/24/jquery-131-go-for-launch/</link>
		<comments>http://blog.perplexedlabs.com/2009/01/24/jquery-131-go-for-launch/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 18:05:32 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=128</guid>
		<description><![CDATA[Just a quick note. I waited for the 1.3.1 release of jQuery to make sure all major bugs had been resolved (brand new selector engine). This weekend I decided to go for the upgrade. Flawless. Even the plugins all worked as expected. Fantastic job. Related posts:jQuery 1.3 Beta Testing jQuery 1.4.2 Released jQuery 1.4 Alpha [...]


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2008/12/22/jquery-13-beta-testing/' rel='bookmark' title='Permanent Link: jQuery 1.3 Beta Testing'>jQuery 1.3 Beta Testing</a></li>
<li><a href='http://blog.perplexedlabs.com/2010/02/20/jquery-1-4-2-released/' rel='bookmark' title='Permanent Link: jQuery 1.4.2 Released'>jQuery 1.4.2 Released</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/12/05/jquery-1-4-alpha-1-released/' rel='bookmark' title='Permanent Link: jQuery 1.4 Alpha 1 Released'>jQuery 1.4 Alpha 1 Released</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Just a quick note.</p>
<p>I waited for the <a href="http://blog.jquery.com/2009/01/21/jquery-131-released/">1.3.1 release of jQuery</a> to make sure all major bugs had been resolved (brand new selector engine).  This weekend I decided to go for the upgrade.  Flawless.  Even the plugins all worked as expected.</p>
<p>Fantastic job.</p>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2008/12/22/jquery-13-beta-testing/' rel='bookmark' title='Permanent Link: jQuery 1.3 Beta Testing'>jQuery 1.3 Beta Testing</a></li>
<li><a href='http://blog.perplexedlabs.com/2010/02/20/jquery-1-4-2-released/' rel='bookmark' title='Permanent Link: jQuery 1.4.2 Released'>jQuery 1.4.2 Released</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/12/05/jquery-1-4-alpha-1-released/' rel='bookmark' title='Permanent Link: jQuery 1.4 Alpha 1 Released'>jQuery 1.4 Alpha 1 Released</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2009/01/24/jquery-131-go-for-launch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery 1.3 Beta Testing</title>
		<link>http://blog.perplexedlabs.com/2008/12/22/jquery-13-beta-testing/</link>
		<comments>http://blog.perplexedlabs.com/2008/12/22/jquery-13-beta-testing/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 18:11:17 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=118</guid>
		<description><![CDATA[The official jQuery blog has announced the availability of jQuery 1.3b1. They're asking for testers to iron out remaining bugs - looking to release on January 14th. Major changes include: Selector Engine - The selector code has undergone a complete rewrite - it’s likely that some edge cases still exist here. DOM Manipulation (append/prepend/before/after) - [...]


Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2008/11/16/converting-from-prototype-to-jquery/' rel='bookmark' title='Permanent Link: Converting from Prototype to jQuery'>Converting from Prototype to jQuery</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/01/24/jquery-131-go-for-launch/' rel='bookmark' title='Permanent Link: jQuery 1.3.1 Go For Launch'>jQuery 1.3.1 Go For Launch</a></li>
<li><a href='http://blog.perplexedlabs.com/2010/02/20/jquery-1-4-2-released/' rel='bookmark' title='Permanent Link: jQuery 1.4.2 Released'>jQuery 1.4.2 Released</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://blog.jquery.com/2008/12/22/help-test-jquery-13-beta-1/" target="_blank">official jQuery blog</a> has announced the availability of jQuery 1.3b1.  They're asking for testers to iron out remaining bugs - looking to release on January 14th.</p>
<p>Major changes include:</p>
<ul>
<li>Selector Engine - The selector code has undergone a complete rewrite - it’s likely that some edge cases still exist here.</li>
<li>DOM Manipulation (append/prepend/before/after) - This code has also undergone a large rewrite along with some of the logic for executing inline script elements.</li>
<li>.offset() - Another method that has been completely rewritten.</li>
<li>Event Namespaces - The logic for handling namespaced events has been completely rewritten.</li>
<li>Event Triggering - When triggering an event the event now bubbles up the DOM - this is likely to cause some problems.</li>
</ul>
<p>Go lend a hand!</p>


<p>Related posts:<ol><li><a href='http://blog.perplexedlabs.com/2008/11/16/converting-from-prototype-to-jquery/' rel='bookmark' title='Permanent Link: Converting from Prototype to jQuery'>Converting from Prototype to jQuery</a></li>
<li><a href='http://blog.perplexedlabs.com/2009/01/24/jquery-131-go-for-launch/' rel='bookmark' title='Permanent Link: jQuery 1.3.1 Go For Launch'>jQuery 1.3.1 Go For Launch</a></li>
<li><a href='http://blog.perplexedlabs.com/2010/02/20/jquery-1-4-2-released/' rel='bookmark' title='Permanent Link: jQuery 1.4.2 Released'>jQuery 1.4.2 Released</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.perplexedlabs.com/2008/12/22/jquery-13-beta-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

