<?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>www.UnseenRevolution.com</title>
	<atom:link href="http://www.unseenrevolution.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.unseenrevolution.com</link>
	<description>Code that changes the world</description>
	<lastBuildDate>Mon, 29 Apr 2013 20:42:36 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Video: Is Node.js Better?</title>
		<link>http://www.unseenrevolution.com/video-is-node-js-better/</link>
		<comments>http://www.unseenrevolution.com/video-is-node-js-better/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 15:52:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[Node.js]]></category>

		<guid isPermaLink="false">http://www.unseenrevolution.com/?p=953</guid>
		<description><![CDATA[Video: Is Node.js Better? Brian Ford weighs in at jsconf 2012]]></description>
				<content:encoded><![CDATA[<p><iframe src="http://blip.tv/play/g_MngvPmZQI.html?p=1" height="300" width="535" frameborder="0" allowfullscreen></iframe><embed type="application/x-shockwave-flash" src="http://a.blip.tv/api.swf#g_MngvPmZQI" style="display:none"></embed></p>
<p>Brian Ford (@brixen ) gives a very interesting talk @ <a href="http://2012.jsconf.us/" title="jsconf 2012">jsconf 2012</a> about the conversation of &#8216;which is better?&#8217;. He points out that humans really don&#8217;t do well at comparing things. </p>
<p>He looks at the support and excitement in the <strong>Node.JS</strong> community. How javascript has a large number of developers, but perhaps has some challenges in the future. Then looks at ruby on rails -vs- node.js. </p>
<h3>About Brian Ford</h3>
<p>Brian has been working on Rubinius since December 2006 and with Engine Yard since January 2008. He created the RubySpec project to improve the standards for high quality, consistent, and compliant Ruby implementations. He hopes to improve Ruby and thereby make the lives of developers even better. He enjoys whisk(e)y but will accept good wine in a pinch. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.unseenrevolution.com/video-is-node-js-better/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Tutorial: Load the jQuery Library from CDN</title>
		<link>http://www.unseenrevolution.com/jquery-library-from-cdn-in-wordpress/</link>
		<comments>http://www.unseenrevolution.com/jquery-library-from-cdn-in-wordpress/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 19:24:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.unseenrevolution.com/?p=914</guid>
		<description><![CDATA[Some might say there is really just 1 thing to remember about making good WordPress website. Make it fast. Speeding up your WordPress site will improve user experience and also improve your sites SEO. Using a CDN to distribute your jQuery library is a great place to start. There are at least 4 reasons you [...]]]></description>
				<content:encoded><![CDATA[<p>Some might say there is really just 1 thing to remember about making good WordPress website. Make it fast. Speeding up your WordPress site will improve user experience and also improve your sites SEO. Using a CDN to distribute your jQuery library is a great place to start. </p>
<p>There are at least 4 reasons you should use a CDN to service jQuery on your page:</p>
<ul id="bigNumOL">
<li><span class="dropcap2">1</span><strong>Decreased Latency</strong><br/>Content Delivery Network — distributes your static content across servers in various physical locations. The User&#8217;s download will automatically target the closest available server in the network.</li>
<li><span class="dropcap2">2</span><strong>Increased parallelism</strong><br/>To avoid needlessly overloading servers, browsers limit the number of connections that can be made simultaneously. Depending on which browser, this limit may be as low as two connections per hostname.</li>
<li><span class="dropcap2">3</span><strong>Better caching</strong><br/>Potentially the greatest benefit of using the Google AJAX Libraries CDN is that your users may not need to download jQuery at all. If your user had downloaded the content in the past, it may already be cached.</li>
<li><span class="dropcap2">4</span><strong>Reduced bandwidth costs</strong><br/>If someone else&#8217;s CDN is pushing the content to your users, they are using their bandwidth, not yours.</li>
</ul>
<p>All of these reasons add up to fast responsive websites. That may be the one thing that everyone agrees is a good thing.</p>
<h3>WordPress: Google&#8217;s jQuery CDN</h3>
<p>I spend a good amount of time working in WordPress environments. Seems like every theme comes with jQuery and the all use the local copy, obviously that is not a great idea, luckly there is a simple way to correct this oversight with just 6 lines of code. </p>
<pre class="brush: php; title: Add to the end of your wordpress theme directory/Functions.php file; notranslate">

function jquery_cdn() {
   if (!is_admin()) {
      wp_deregister_script('jquery');
      wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', false, '1.7.2');
      wp_enqueue_script('jquery');
      }
   }
add_action('init', 'jquery_cdn');

</pre>
<h3>Other jQuery CDN options</h3>
<p>While I recommend using the Google CDN because it is so widely used and therefore increases the changes it will already be in your user&#8217;s cache, there are several other options.<br />
<strong>Google&#8217;s jQuery CDN</strong><br/>http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js</p>
<p><strong>Microsoft&#8217;s jQuery CDN</strong><br/>http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js</p>
<p><strong>jQuery&#8217;s CDN</strong><br/>http://code.jquery.com/jquery-1.7.2.min.js</p>
<h3>Other jQuery CDN Version Options</h3>
<p>Most of the CNDs listed above will also service other versions of jQuery. For example if you wish to use jQuery 1.5.2 from Google&#8217;s CDN it is simply a matter of requesting http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unseenrevolution.com/jquery-library-from-cdn-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery $(document).ready() shorthand &#8211; domready</title>
		<link>http://www.unseenrevolution.com/jquery-document-ready-shorthand/</link>
		<comments>http://www.unseenrevolution.com/jquery-document-ready-shorthand/#comments</comments>
		<pubDate>Sun, 08 Apr 2012 17:00:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.unseenrevolution.com/?p=890</guid>
		<description><![CDATA[ jQuery $(document).ready() function is guaranteed to be executed after the DOM is ready.Here are a few variations including shorthand and noConflict.]]></description>
				<content:encoded><![CDATA[<h3>jQuery .ready()</h3>
<p>JavaScript provides the load event for executing code when a page is rendered. This event gets triggered when the download assets such as images has completed. However, most people want their script to run as soon as the DOM hierarchy has been fully constructed. jQuery provides the <strong>.ready()</strong> for just this purpose. This is the corresponding <strong>domready</strong> function in Mootools.</p>
<pre class="brush: jscript; title: jQuery Ready Function; notranslate">
$(document).ready(function() {
  // your code
  alert('Page: ' + $('title').html() + ' dom loaded!');
});
</pre>
<pre class="brush: jscript; title: Shorter but equivalent jQuery Ready Function; notranslate">
$(function() {
 // Handler for .ready() called.
 alert('Page: ' + $('title').html() + ' dom loaded!');
});
</pre>
<pre class="brush: jscript; title: jQuery noConflict Ready Function; notranslate">
jQuery.noConflict();
(function($) { 
  $(function() {
   // by passing the $ you can code using the $ alias for jQuery
   alert('Page: ' + $('title').html() + ' dom loaded!');
  });
})(jQuery);
</pre>
<h3>.ready() Handler</h3>
<p>The handler passed to .ready() is guaranteed to be executed after the DOM is ready. This is usually the best place to attach all other event handlers and run other jQuery code. If .ready() is called after the DOM has been initialized, the new handler passed in will be executed immediately.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unseenrevolution.com/jquery-document-ready-shorthand/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Ajax Post</title>
		<link>http://www.unseenrevolution.com/jquery-ajax-post/</link>
		<comments>http://www.unseenrevolution.com/jquery-ajax-post/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 19:51:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.unseenrevolution.com/?p=869</guid>
		<description><![CDATA[jQuery provides a quick, robust and easy way to request data from the server without a page reload through AJAX. In this short article we&#8217;ll look at loading data from the server using a HTTP Post Request. jQuery $.post function There is a shorthand AJAX post function with the following signature: jQuery $.ajax Post Function [...]]]></description>
				<content:encoded><![CDATA[<p>jQuery provides a quick, robust and easy way to request data from the server without a page reload through AJAX. In this short article we&#8217;ll look at loading data from the server using a HTTP Post Request.</p>
<h3>jQuery $.post function</h3>
<p>There is a shorthand AJAX post function with the following signature:</p>
<pre class="brush: jscript; title: jQuery Ajax Post Function; notranslate">$.post({
  url: 'myTargetURL.php',
  data: data,
  success: success function(data, textStatus, jqXHR),
  dataType: dataType
});</pre>
<h3>jQuery $.ajax Post Function</h3>
<p>I prefer to use the default .ajax function for ease of use and maintainability.</p>
<pre class="brush: jscript; title: Preferred $.ajax Post function; notranslate">
$.ajax({
type: 'POST',
url: 'myTargetURL.php',
data: data,
success: success function(data, textStatus, jqXHR),
complete: function(),
dataType: dataType
});
</pre>
<div class="avia-box info"><span class="avia-innerbox">You&#8217;ll notice that they both accomplish the same thing, however, the $.ajax function has more flexibility. Just a personal preference.</span></div>
<h3>jQuery AJAX Post Parameters</h3>
<p>Here is the rundown on pass parameter:<br />
<strong>type</strong> &#8211; HTTP Request Type. In this case &#8216;<strong>POST</strong>&#8216;, but could be &#8216;<strong>GET</strong>&#8216; as well.<br />
<strong>url</strong> &#8211; A string containing the URL to which the request is sent. Eg: HTTP://www.Yourdomain.com/YourAjaxScript.php</p>
<p><strong>data</strong> &#8211; A map or string that is sent to the server with the request. </p>
<p><strong>success(data, textStatus, jqXHR)</strong> &#8211; A callback function that is executed if the request succeeds.</p>
<p><strong>complete()</strong> &#8211; A callback function that is executed when everything is complete.</p>
<p><strong>dataType</strong> &#8211; The type of data expected from the server. Default: Intelligent Guess (<strong>xml</strong>, <strong>json</strong>, <strong>script</strong>, <strong>text</strong>, <strong>html</strong>).</p>
<h3>jQuery Ajax Error Handling</h3>
<p>The jQuery $.ajax function has a very robust error handling system. You can read more about it&#8217;s implementation in the <a href="http://www.unseenrevolution.com/jquery-ajax-error-handling-function/"> jQuery Ajax Error Handling Function post</a>.</p>
<h3>jQuery Ajax Post Example</h3>
<pre class="brush: jscript; title: jQuery Ajax Post Code; notranslate">
$.ajax({
        url: &quot;/form.php&quot;,
        type: &quot;post&quot;,
        data: serializedData,
        // callback handler that will be called on success
        success: function(response, textStatus, jqXHR){
            // log a message to the console
            console.log(&quot;It worked!&quot;);
        },
        // callback handler that will be called on completion
        // which means, either on success or error
        complete: function(){
            // enable the inputs
            $inputs.removeAttr(&quot;disabled&quot;);
        }
    });
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.unseenrevolution.com/jquery-ajax-post/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Local SEO Lessons</title>
		<link>http://www.unseenrevolution.com/google-local-seo-lessons/</link>
		<comments>http://www.unseenrevolution.com/google-local-seo-lessons/#comments</comments>
		<pubDate>Tue, 20 Mar 2012 15:56:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Local]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.unseenrevolution.com/?p=810</guid>
		<description><![CDATA[SEO - Get your business listed on Google Maps, Google places, and Google Local search. -  Easy Steps to ranking #1 in Google Local.]]></description>
				<content:encoded><![CDATA[<h2>Getting Your Business on Google Maps</h2>
<p>If you’re a local business and are looking to drive local customers to your business site, a great place to start is <strong>Google places</strong> and <strong>Google maps</strong>. According to a new study from Bizible there are a few easy things you can do to improve your SEO and move up in the Google local rankings.</p>
<h3>Two Parts to a Local Search Query:</h3>
<ul id="bigNumOL">
<li><span class="dropcap2">1</span>The search city &#8211; “Portland” when searching for “Portland pizza.”</li>
<li><span class="dropcap2">2</span>The search category &#8211; “pizza” when searching for “Portland pizza.” We also generated a list of synonyms for the search category</li>
</ul>
<h3>Integrated Search Results Factors:</h3>
<ul id="bigNumOL">
<li><span class="dropcap2">1</span>Having the primary category match a broader category of the search category was associated with a 1.42 improvement in rank. For example, primary category is set to &#8220;restaurant&#8221; and the search category was &#8220;pizza.&#8221;</li>
<li><span class="dropcap2">2</span>Having the search category or a synonym in the business name was associated with a 0.64 improvement in rank.</li>
<li><span class="dropcap2">3</span>Having the search category or a synonym in “at a glance” was associated with a 0.36 improvement in rank.</li>
<li><span class="dropcap2">4</span>Having five or more Google reviews was associated with a 0.31 improvement in rank.(more than 5 does little to improve your rank)</li>
<li><span class="dropcap2">5</span>Having photos (at least 1) was associated with a 0.25 improvement in rank.</li>
</ul>
<p style="clear: both;">The average ranking improvement for listing that implement these suggestions improved by about three positions. That is significant when you realize that on average there are only 5 integrated results listed for a search.</p>
<h3>Pure Local Search Results Factors:</h3>
<ul id="bigNumOL">
<li><span class="dropcap2">1</span>Having five or more Google reviews was associated with a 1.47 improvement in rank.</li>
<li><span class="dropcap2">2</span>Having the search city in “at a glance” was associated with a 1.42 improvement in rank.</li>
<li><span class="dropcap2">3</span>Having the search category or a synonym in in review content was associated with a 0.97 improvement in rank.</li>
<li><span class="dropcap2">4</span>Having the search category or a synonym in the business description was associated with a 0.85 improvement in rank.</li>
<li><span class="dropcap2">5</span>Having the search category or a synonym in “at a glance” was associated with a 0.85 improvement in rank.</li>
<li><span class="dropcap2">6</span>Having the primary category match the search category was associated with a 0.79 improvement in rank.</li>
<li><span class="dropcap2">7</span>Having the search category or a synonym in in the business name was associated with a 0.75 improvement in rank.</li>
<li><span class="dropcap2">8</span>Having a secondary business category that was a broader category than the search category was associated with a 0.68 improvement in rank. i.e. secondary category is “restaurant” when searching for “Portland pizza.”</li>
<li><span class="dropcap2">9</span>Having at least one photo was associated with a 0.66 improvement in rank.</li>
<li><span class="dropcap2">10</span>Owner verified was associated with a 0.52 improvement in rank.</li>
</ul>
<p style="clear: both;">Listings using these factors on average saw a ranking improvement of 9 positions.</p>
<h3>Search Engine Optimization Consulting</h3>
<p>As you can see there are a few things to do to make a big difference in the SEO of your business listing. We at Unseen Revolution are search engine optimization specialists and can help you improve search engine ranking, list on Google Places for business, or list your business on Google maps.</p>
<p>The full report can be reviewed by visiting <a title="bizible.com" href="http://bizible.com/local-search-ranking-factors/google-places-optimization">bizible.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.unseenrevolution.com/google-local-seo-lessons/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Solution: Firefox Font-Face Cross Domain Problem</title>
		<link>http://www.unseenrevolution.com/solution-firefox-font-face-cross-domain-problem/</link>
		<comments>http://www.unseenrevolution.com/solution-firefox-font-face-cross-domain-problem/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 17:14:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://www.unseenrevolution.com/?p=839</guid>
		<description><![CDATA[Fix the Firefox font-face cross domain problem with a simple change to the .htaccess file.]]></description>
				<content:encoded><![CDATA[<h3>Firefox Font-Face Cross Domain Problem:</h3>
<p>The other day I was working on a website that we were accelerating with a content deliver network (CDN). All the static content was to go through the cdn including the styles (css) file. We ran into a weird bug on Firefox. Font-face styles were not showing. The fonts were loading off the cdn.mysite.com sub domain while the rest of the site was running off mysite.com.</p>
<pre class="brush: css; title: Font-Face Style; notranslate">@font-face{
	font-family:'PreloSlab';
	src:url('../fonts/preloslab-medium-webfont.eot');
	src:url('../fonts/preloslab-medium-webfont.eot?#iefix') format('embedded-opentype'),
		url('../fonts/preloslab-medium-webfont.woff') format('woff'),
		url('../fonts/preloslab-medium-webfont.ttf') format('truetype'),
		url('../fonts/preloslab-medium-webfont.svg#PreloSlabMedium') format('svg');
	font-weight:normal;font-style:normal
	}</pre>
<h3>Reason:</h3>
<p>Seems that Firefox supports the <a href="http://www.w3.org/TR/cors/">Cross-Origin Resource Sharing standard (CORS)</a> for HTTP requests of some types of resource. This is a way for a remote host to control access to some types of resource. As it turns out, web fonts are subject to CORS. So, the appropriate Access Control headers need to be sent to the browser to allow the domain originating the request (the Origin) access to the resource.</p>
<h3>Firefox Font-Face Cross Domain Solution:</h3>
<p>Seems messy but it really isn’t. The correct header is:</p>
<pre class="brush: plain; title: HTTP Header; notranslate">Access-Control-Allow-Origin: http://mysite.com</pre>
<p>On an Apache server you can accomplish this with a little edit to the .htaccess file.</p>
<pre class="brush: xml; title: Added to .htaccess file; notranslate">
&lt;FilesMatch &quot;\.(ttf|ttc|otf|eot|woff|font.css)$&quot;&gt;
  &lt;IfModule mod_headers.c&gt;
    Header set Access-Control-Allow-Origin &quot;http://mysite.com&quot;
  &lt;/IfModule&gt;
&lt;/FilesMatch&gt;
</pre>
<div class="avia-box info"><span class="avia-innerbox">Note: while you should be able to list several domains separated by a comma. This did not work. I had to use <strong>Header set Access-Control-Allow-Origin &#8220;*&#8221; for multiple domains</strong>.</span></div>
<h3>Font-Face Mime Types</h3>
<p>While you are at it, you can also add the correct mime types to the files.</p>
<pre class="brush: plain; title: Mime Types; notranslate">AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff woff</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.unseenrevolution.com/solution-firefox-font-face-cross-domain-problem/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery .Ajax Error Handling Function</title>
		<link>http://www.unseenrevolution.com/jquery-ajax-error-handling-function/</link>
		<comments>http://www.unseenrevolution.com/jquery-ajax-error-handling-function/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 22:35:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.unseenrevolution.com/?p=702</guid>
		<description><![CDATA[.ajaxSetup() for jQuery  AJAX error handling: HTTP Status Code 404/500 errors, and JSON parse errors for $.get, $.post, $.ajax calls.]]></description>
				<content:encoded><![CDATA[<h3>jQuery Ajax Request &#8211; Background</h3>
<p>The jQuery library provided easy access to AJAX requests with the following functions <strong><a title="jQuery get function" href="http://api.jquery.com/jQuery.get/">$.get</a>, <a title="jQuery post function" href="/jquery-ajax-post/">$.post</a>, <a title="jQuery ajax function" href="/jquery-ajax-post/">$.ajax</a></strong>:</p>
<pre class="brush: jscript; title: jQuery Ajax Function; notranslate">$.ajax({
  url: &quot;test.html&quot;,
  context: document.body,
  success: function(){
    //do something on success
  }
});</pre>
<p>The <strong>jQuery ajax error function</strong> hook is part of the callback function queues. When the callback is invoked it receives the <a title="jQuery ajax jqXHR object" href="http://api.jquery.com/jQuery.ajax/#jqXHR">jqXHR</a>, a string indicating the error type, and an exception object if applicable. There are several built in error strings provided by the exception option they include &#8220;<strong>abort</strong>&#8220;, &#8220;<strong>timeout</strong>&#8220;, &#8220;<strong>No Transport</strong>&#8220;, &#8220;<strong>parser error</strong>&#8220;. We also have access to server errors that are returned. In this implementation we want to catch the following.</p>
<ol>
<li>HTTP Status Code <strong>404 Error</strong> &#8211; ajax file not found error</li>
<li>HTTP Status Code <strong>500 Error</strong> &#8211; ajax internal system error</li>
<li><strong>AJAX JSON Parse</strong> Errors</li>
<li><strong>jQuery AJAX Timeout</strong> Errors</li>
<li><strong>jQuery AJAX Abort</strong> Errors</li>
<li>Browser/Connectivity Errors</li>
<li><strong>AJAX no transport error</strong></li>
<li>Other Unknown Errors</li>
</ol>
<h3>jQuery .ajaxSetup() Function</h3>
<p>It is possible to set default values for all jQuery AJAX requests using the <a title="jQuery ajaxSetup function" href="http://api.jquery.com/jQuery.ajaxSetup/">JQuery .ajaxSetup()</a>function. The function is used to set default key/value pairs for all future AJAX requests. Looks like this:</p>
<pre class="brush: jscript; title: jQuery ajaxSetup Function; notranslate">$.ajaxSetup({
     key: 'value'
});</pre>
<h3>jQuery Ajax Error Function</h3>
<p>Let&#8217;s start building the function the will return the Ajax error. It will be a series of if else statements to text the chain of possible errors. We&#8217;ll test in a specific order and set an alert for each of the caught errors. We&#8217;ll also set the new function to the default error handling function with <strong>$.ajaxSetup()</strong>.</p>
<div style="position: relative;z-index:900">
<div  style="left: 385px;position: absolute;top: 24px;width: 165px;z-index: 901;">
      Share the love! <g:plusone size="small"></g:plusone>
    </div>
</div>
<pre class="brush: jscript; title: jQuery Ajax Error Handling Function; notranslate">
$(function() {
	$.ajaxSetup({
		error: function(jqXHR, exception) {
			if (jqXHR.status === 0) {
				alert('Not connect.\n Verify Network.');
			} else if (jqXHR.status == 404) {
				alert('Requested page not found. [404]');
			} else if (jqXHR.status == 500) {
				alert('Internal Server Error [500].');
			} else if (exception === 'parsererror') {
				alert('Requested JSON parse failed.');
			} else if (exception === 'timeout') {
				alert('Time out error.');
			} else if (exception === 'abort') {
				alert('Ajax request aborted.');
			} else {
				alert('Uncaught Error.\n' + jqXHR.responseText);
			}
		}
	});
});
</pre>
<p>Once the default error handling action is set, you can leverage it by calling the existing jQuery ajax functions.</p>
<h3>Ajax Error handling Examples:</h3>
<pre class="brush: jscript; title: jQuery .ajax, .get, .post Example; notranslate">
// jQuery AJAX Error Handler
$.ajax({
  url: &quot;test.php&quot;
});

or
// jQuery AJAX Get Error Handler
$.get(&quot;test.php&quot;);

or
// jQuery AJAX post Error Handler
$.post(&quot;test.php&quot;);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.unseenrevolution.com/jquery-ajax-error-handling-function/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>jQuery External Links &#8211; Open in New Window</title>
		<link>http://www.unseenrevolution.com/jquery-external-links-new-window/</link>
		<comments>http://www.unseenrevolution.com/jquery-external-links-new-window/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 16:43:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.unseenrevolution.com/?p=541</guid>
		<description><![CDATA[Use jQuery and CSS to automatically open any external link in a new window. Style external link for improved visual impact. ]]></description>
				<content:encoded><![CDATA[<p>When it comes to website management links are huge. Most people realize that if they have a link off their site that it is a possibility that they will loose person. Now, if the goal for your website it to keep customers where they can buy from you, it makes sense to never send a customer away.</p>
<p>However, the web is an amazing place with a huge amount of information. Your site can&#8217;t have all the info. Also, linking to quality content will also improve your SEO. So, you might just end up with more people visiting your site if you share the wealth around a little. But how can you have your cake and eat it too? Well, you could open a new browser window when you were sending someone to another site. That would mean that when they closed that windows, your site would still be there. Just so they don&#8217;t get lost.</p>
<p>Today, I am going to produce some code that will automatically open a new window for any external link and also show you how to dress up these links so that people will know that they are going to take them off your site. Hopefully, it will be a useful tutorial in some of the great features built right into jQuery.</p>
<p><span class="dropcap2">1</span><strong>jQuery Selectors</strong><br />
jQuery has some amazing capabilities when it comes to its built in <a href="http://api.jquery.com/category/selectors/">selectors</a> for html elements. In this case, it makes good sense to use a selector to get all the links on the page and then use the jQuery <a href="http://api.jquery.com/each/">each()</a> function to iterate through each found link and test it to see if it links to an external site.</p>
<p>We&#8217;ll test if the link&#8217;s hostname matches the pages <a href="http://www.w3schools.com/jsref/prop_loc_hostname.asp">hostname</a>. If they don&#8217;t we&#8217;ll know that the link is to another site and then we can do some additional work on it. The code looks like this:</p>
<pre class="brush: jscript; title: a tag selector and external link test; notranslate">$(&quot;a[href*='http://']:not([href*='&quot;+location.hostname.replace
           (&quot;www.&quot;,&quot;&quot;)+&quot;'])&quot;).each(function() {
		//do some 'stuff' to the external link
	});</pre>
<p><span class="dropcap2">2</span><strong>Alter The External Link</strong><br />
I want to add a new class to each external link (I&#8217;ll cleverly call this class &#8216;externalLink&#8217;). We&#8217;ll use the jQuery <a href="http://api.jquery.com/addClass/">.addClass()</a> function. We&#8217;ll use the <a href="http://api.jquery.com/click/">.click()</a> function to modify the existing onclick event for the link. Note: we could have added a target=&#8221;_blank&#8221; attribute, but that would not be xhtml compliant. These can be chained onto one line for efficiency.</p>
<pre class="brush: jscript; title: add class and window.open event; notranslate">jQuery(this).click(function(event) {
     event.preventDefault();
     event.stopPropagation();
     window.open(this.href, '_blank');
}).addClass('externalLink');</pre>
<p>At this point the code is also complete. We want this code to fire when the page loads. So, we will wrap the code in the jQuery <a href="/jquery-document-ready-shorthand/"><strong>.ready()</strong></a> event handler. There is a shorthand that is great, we&#8217;ll use it here.</p>
<pre class="brush: jscript; title: function to execute after the DOM is ready.; notranslate">$(function() {
 // Handler for .ready() called.
});</pre>
<p>Lastly, I wanted to style the external links differently from all the other links. We have already added the new class, &#8216;externalLink&#8217;, to the link element. I wanted to add an icon similar to how Wikipedia does. So, we&#8217;ll want to add a couple lines of css to the styles.</p>
<pre class="brush: css; title: .externalLink css; notranslate">.externalLink {
    background: url(&quot;/images/externalLink.png&quot;) no-repeat scroll right center transparent;
    padding-right: 13px;
}</pre>
<p><span class="dropcap2">3</span><strong>Putting It All Together</strong><br />
When we put it all together it is a simple, elegant and extremely useful solution. Here is the final code:</p>
<pre class="brush: jscript; title: Javascript; notranslate">$(function() {
   $(&quot;a[href*='http://']:not([href*='&quot;+location.hostname.replace
           (&quot;www.&quot;,&quot;&quot;)+&quot;'])&quot;).each(function() {
       $(this).click(function(event) {
             event.preventDefault();
             event.stopPropagation();
             window.open(this.href, '_blank');
        }).addClass('externalLink');
   });
});</pre>
<pre class="brush: css; title: CSS; notranslate">.externalLink {
    background: url(&quot;/images/externalLink.png&quot;) no-repeat scroll right center transparent;
    padding-right: 13px;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.unseenrevolution.com/jquery-external-links-new-window/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>jQuery Lightbox</title>
		<link>http://www.unseenrevolution.com/jquery-lightbox/</link>
		<comments>http://www.unseenrevolution.com/jquery-lightbox/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 18:17:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.unseenrevolution.com/?p=487</guid>
		<description><![CDATA[So, the other day I was building a popup dialog box based on the principals seen in most light boxes. I wanted the box to be centered top and bottom and left and right. The obvious choice was to use jQuery, but I wanted something that would be reusable. Seemed like there were 3 parts [...]]]></description>
				<content:encoded><![CDATA[<p>So, the other day I was building a popup dialog box based on the principals seen in most light boxes. I wanted the box to be centered top and bottom and left and right. The obvious choice was to use jQuery, but I wanted something that would be reusable.</p>
<p>Seemed like there were 3 parts to the problem.</p>
<ol>
<li>Center the dialogue box</li>
<li>Grey out the background</li>
<li>Hide all of the lightbox when someone clicks off the lightbox</li>
</ol>
<p><span class="dropcap2">1</span> <strong>Centering the dialogue box</strong><br />
I found a start at <a href="http://stackoverflow.com/questions/210717/what-is-the-best-way-to-center-a-div-on-the-screen-using-jquery/210733#210733">Stack Overflow</a>, while a great start, it seemed to be missing a few things that I was looking for.</p>
<pre class="brush: jscript; title: ; notranslate">jQuery.fn.UnseenCenter = function() {
	this.css({
		&quot;position&quot;: &quot;absolute&quot;});
	this.css({
		&quot;top&quot;: (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + &quot;px&quot;,
		&quot;left&quot;: (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + &quot;px&quot;
	});
	return this;
};</pre>
<p>The code extends the jQuery Framework and creates a new function called &#8216;UnseenCenter&#8217; that can be called in association with any element on the page. Note: when getting calculating the element&#8217;s size we are using the jQuery <a href="http://api.jquery.com/outerHeight/" target="_blank">outerHeight()</a> and <a href="http://api.jquery.com/outerWidth/" target="_blank">outerWidth()</a> to insure that we are taking padding and margins into account.</p>
<p>For the box itself, we can use a div that is styled with CSS. Now, we want to insure that the jQuery code is <a href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript" target="blank">unobtrusive</a> so we will use classes and ids to manage <a href="http://api.jquery.com/click/" target="_blank">onClick()</a> events that show and hide the lightbox. In this case I chose a class called &#8216;UnseenLightbox&#8217; that will be used to associate and element with the click event.</p>
<p>To enable multiple lightboxes on the same page we need to create some code that will allow us to target specific lightbox content with the click() event. To do that I created a class/ID hi-bred solution. Every element that has the class &#8216;UnseenLightbox&#8217; will also have a class with a particular format &#8216;UnseenTarget-DivID&#8217; where the &#8216;DivID is the id of the lightbox element to be displayed.</p>
<p>Here is the HTML so far:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;a href='#' class='UnseenLightbox UnseenTarget-DivID'&gt;click here for lightbox&lt;/a&gt;
&lt;div id=&quot;DivID&quot; class='Unseenlightbox-content' style=&quot;display:none;&quot;&gt;
	You can put anything here:
	&lt;ol&gt;
			&lt;li&gt;Images&lt;/li&gt;
			&lt;li&gt;Lists&lt;/li&gt;
			&lt;li&gt;Forms&lt;/li&gt;
	&lt;/ol&gt;
	Use CSS to make this look great!
&lt;/div&gt;
</pre>
<p>We&#8217;ll use the $(document)<a href="http://api.jquery.com/ready/" target="_blank">.ready(handler)</a> to run through the dom when loaded and connect the onClick events for each of the elements to the targeted lightbox content. To do that, we&#8217;ll look at each &#8216;UnseenLightbox&#8217; classed element and check that it has a &#8216;UnseenTarget-DivID&#8217; class. If it does, we have all the information we need to set an onClick event targeting the correct lightbox div.  It looks like this:</p>
<pre class="brush: jscript; title: ; notranslate">$(function() {
	$('.UnseenLightbox').each(function(index) {
		$(this).click(function() {
			targetDivID = null;
			$.each($(this).attr('class').split(' '), function(index, item) {
				if (this.indexOf(&quot;UnseenTarget-&quot;) === 0) {
					targetDivID = item.replace('UnseenTarget-', '');
				}
			});
			if (targetDivID != null) {
				$('#' + targetDivID).UnseenLightboxShow();
			}

		});

	});

});</pre>
<p><span class="dropcap2">2</span> <strong>Greying the background</strong><br />
This is one of these things that is useful to make sure the user focuses on the dialogue and does not get distracted. We&#8217;ll also make it so that if the user clicks on the greyed background that the dialogue will close. We&#8217;ll do this with a div that we&#8217;ll <a href="http://api.jquery.com/append/" target="_blank">.append()</a> to the dom with jQuery. We can check to insure we only do this once by checking to see if the element exists in the dom.</p>
<pre class="brush: jscript; title: ; notranslate">jQuery.fn.exists = function() {
	return jQuery(this).length &gt; 0;
}
if (!$('#UnseenBackgroundDiv').exists()) {
	$('body').append('&lt;div id=&quot;UnseenBackgroundDiv&quot;&gt;');
}&lt;/div&gt;</pre>
<p>Now that we have the background div in the dom, we&#8217;ll want to place it so that it covers the whole background. We&#8217;ll do that by setting the some CSS attributes with the jQuery <a href="http://api.jquery.com/css/" target="_blank">.css()</a> function. We&#8217;ll need to know how large the document is. We can use $(document)<a href="http://api.jquery.com/height/" target="_blank">.height()</a> and $(document).<a href="http://api.jquery.com/width/" target="_blank">width()</a> to get that. We are going to want to absolute position the background and set its <a href="http://www.w3schools.com/css/pr_pos_z-index.asp" target="_blank">z-index</a> so that it will be over everything but the lightbox.</p>
<p>Now, just so that it is pretty, we can use the <a href="http://api.jquery.com/fadeTo/">.fadeTo()</a>, <a href="http://api.jquery.com/fadeIn/">.fadeIn()</a>, and <a href="http://api.jquery.com/fadeOut/">.fadeOut()</a> effect functions from jQuery. We can use these on the targeted content div as well as the grey background.</p>
<pre class="brush: jscript; title: ; notranslate">jQuery.fn.UnseenLightboxShow = function() {
	if (!$('#UnseenBackgroundDiv').exists()) {
		$('body').append('&lt;div id=&quot;UnseenBackgroundDiv&quot;&gt;');
		$('#' + 'UnseenBackgroundDiv').click(function() {
			$(this).UnseenLightboxHide();
		});
	}
	$('#' + 'UnseenBackgroundDiv').hide();
	$('#' + 'UnseenBackgroundDiv').css({
		&quot;top&quot;: 0,
		&quot;left&quot;: 0,
		&quot;height&quot;: $(document).height() + &quot;px&quot;,
		&quot;width&quot;: $(document).width() + &quot;px&quot;,
		&quot;position&quot;: &quot;absolute&quot;;
		&quot;background-color&quot;:&quot;black&quot;,
		&quot;z-index&quot;: &quot;9000&quot;
	});
	$(this).css(&quot;z-index&quot;, '9100');
	$('#' + 'UnseenBackgroundDiv').fadeTo('slow', .7, function() {});
	$(this).fadeIn('slow', function() {}).center();
};&lt;/div&gt;</pre>
<p><span class="dropcap2">3</span> <strong>Close the Lightbox</strong><br />
Most of the heavy lifting is complete. We&#8217;ll create just one more jQuery function called &#8216;UnseenLightboxHide&#8217; that when called will fade all the lightbox elements out. We&#8217;ll also need to add some code to call the function when someone clicks on the background.</p>
<pre class="brush: jscript; title: ; notranslate">jQuery.fn.UnseenLightboxHide = function() {
	$('#' + 'UnseenBackgroundDiv').fadeOut('slow', function() {});
	$('.Unseenlightbox-content').fadeOut('slow', function() {});
}
$('#' + 'UnseenBackgroundDiv').click(function() {
	$(this).UnseenLightboxHide();
});</pre>
<h3>Conclusion</h3>
<p>I hope this tutorial was helpful. There are a couple interesting problems we solved today. Something we did not implement that would be very helpful would be a quick couple of lines that would recenter the lightbox when someone resizes the browser window. It would be fairly easy to refactor the code and implement jQuery&#8217;s <a href="http://api.jquery.com/resize/" target="_blank">.resize()</a> function.</p>
<h3>Demo and Files</h3>
<p>You can look at a quick demo can be found at <a href="/tutorials/lightbox/lightbox.html">Lightbox Demo</a>.</p>
<p>The javascript file can be found <a href="/tutorials/lightbox/lightbox.js">Here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unseenrevolution.com/jquery-lightbox/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached
Page Caching using disk: enhanced
Object Caching 1137/1158 objects using apc

 Served from: www.unseenrevolution.com @ 2013-05-18 18:47:04 by W3 Total Cache -->