<?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>nFriedly Web Dev Tech Blog &#187; ajax</title>
	<atom:link href="http://nfriedly.com/techblog/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://nfriedly.com/techblog</link>
	<description>Expert Advice on Website Development, Javascript, Ajax, and Security</description>
	<lastBuildDate>Wed, 01 Feb 2012 22:35:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Calling all (available) Web Designers &amp; Developers</title>
		<link>http://nfriedly.com/techblog/2010/12/calling-all-avaiable-web-designers-developers/</link>
		<comments>http://nfriedly.com/techblog/2010/12/calling-all-avaiable-web-designers-developers/#comments</comments>
		<pubDate>Fri, 17 Dec 2010 17:29:24 +0000</pubDate>
		<dc:creator>nFriedly</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://nfriedly.com/techblog/?p=329</guid>
		<description><![CDATA[Even though I&#8217;ve been happily employed with Sociable Labs for a while now, I still get fairly frequent calls and emails from people who want to know if I&#8217;m available or I &#8220;know someone.&#8221; The list of people I know is starting to run short, so this post is intended to remedy that. If you [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://nfriedly.com/techblog/2010/12/calling-all-avaliable-web-designers-developers"><img class="alignright size-full wp-image-358" title="Ring Ring!" src="http://nfriedly.com/techblog/wp-content/uploads/2010/12/1171473_phone_home-min.jpg" alt="" width="200" height="245" /></a>Even though I&#8217;ve been happily employed with <a href="http://sociablelabs.com/">Sociable Labs</a> for a while now, I still get fairly frequent calls and emails from people who want to know if I&#8217;m available or I &#8220;know someone.&#8221; The list of people I know is starting to run short, so this post is intended to remedy that.</p>
<p><strong>If you are an individual Web Designer or Web Developer interested in work, please post a comment below.</strong></p>
<p><strong><span id="more-329"></span></strong>What to post:</p>
<ul>
<li>Your name and website in the appropriate fields. I disabled WordPress&#8217;s <code>rel="nofollow"</code> just for you.
<ul>
<li>If you don&#8217;t have a website, get one! Sign up for a <a href="http://www.dreamhost.com/r.cgi?225072">Dreamhost account</a> and buy a template from <a href="http://themeforest.net/?ref=nfriedly">Theme Forest</a> and you&#8217;ll have a solid website in no time.</li>
</ul>
</li>
<li>Your basic skillset. For me, it might be &#8220;Strong Javascript / Ajax, PHP, HTML, and CSS; basic Photoshop, ActionScript and Java&#8221;</li>
<li>A short bit about yourself and your experience.</li>
<li>Where you&#8217;re located, and if you would consider relocating for work.</li>
<li>What type of work you&#8217;re interested in: freelance / short-term contract (3-6 months or less), long-term contract, employment, startup, etc.</li>
</ul>
<p>Tips:</p>
<ul>
<li>This is your first impression to potential clients: Copy-paste it into Word and read it out loud once or twice. Get it right the first time because you can&#8217;t edit comments after you&#8217;ve posted them.</li>
<li>Contact information: any phone number or email address posted here will be picked up by spammers.
<ul>
<li> A basic solution is to just post a .jpg on your website with your phone number and email.</li>
<li>A better solution could be a contact form like this one: <a href="http://nfriedly.com/techblog/2009/06/how-to-build-a-spam-free-contact-forms-without-captchas/">How to build a spam-free contact form without captchas</a></li>
</ul>
</li>
<li>One or two links to your GitHub, LinkedIn, or recent work is fine, but be warned that my WordPress marks<strong> </strong>anything with <strong>more than 3 links as spam</strong>, and it&#8217;s hidden until I get around to checking the spam filter.</li>
<li>Lastly, this is my website, and I may choose to edit or delete comments. For example, if you claim 10+ years experience with jQuery, your comment will be deleted. (JQuery was released in 2006)</li>
</ul>
<p>Thanks and best wishes with your future work!</p>
]]></content:encoded>
			<wfw:commentRss>http://nfriedly.com/techblog/2010/12/calling-all-avaiable-web-designers-developers/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>How AJAX Security and Twitter callbacks work</title>
		<link>http://nfriedly.com/techblog/2009/06/javascript-security-ajax-json-and-twitter-callbacks/</link>
		<comments>http://nfriedly.com/techblog/2009/06/javascript-security-ajax-json-and-twitter-callbacks/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 14:40:33 +0000</pubDate>
		<dc:creator>nFriedly</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://nfriedly.com/techblog/2009/06/javascript-security-ajax-json-and-twitter-callbacks/</guid>
		<description><![CDATA[The twitter callback feature is nice &#8211; it makes it extremely easy to to add a twitter feed to a page. But to get the most benefit out of it, you really need to understand what it&#8217;s doing. We&#8217;re going to look at how AJAX security works, specifically the Same Origin Policy, how Twitter gets [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" title="Breaking javascript - the right way" src="http://www.sxc.hu/pic/m/s/si/simonok/323276_game_of_pool.jpg" alt="" width="141" height="188" />The twitter callback feature is nice &#8211; it makes it extremely easy to to add a twitter feed to a page. But to get the most benefit out of it, you really need to understand what it&#8217;s doing.</p>
<p>We&#8217;re going to look at how AJAX security works, specifically the Same Origin Policy, how Twitter gets around it, and the type of callback that twitter uses.</p>
<p>Note: the callback that twitter uses is entirely different from callback in the sense of passing a javascript function around as a variable. We&#8217;ll look at that in a future article.</p>
<p><span id="more-114"></span></p>
<h2>AJAX Security</h2>
<p>The XMLHTTPRequest Object, which is the javascript object used to make AJAX requests, has a &#8220;<a href="https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript">Same Origin Policy</a>&#8221; which basically means that javascript on site1.com cannot use AJAX to directly load data from site2.com. This is a security feature, as it makes XSS (Cross-Site Scripting) attacks more difficult.</p>
<p>Worth noting, if the website is at site1.com, no scripts can communicate with any other site, even if the script was loaded from site2.com.</p>
<h2>Work Arounds</h2>
<p>There are a number of workarounds including iframes, java applets, and flash, but here&#8217;s a couple of the more common methods.</p>
<h3><img src="http://www.sxc.hu/pic/m/c/cw/cwmgary/486891_all_lined_up.jpg" alt="Line em up!" class="alignright" />Proxying Requests</h3>
<p>The way proxying works is to have a file on your server that grabs the data from a remote server and passes it along. Then for javascript, the data appears to be coming from your server, even though it actually originated at a remote server. This is what the Fancy part of my <a href="http://nfriedly.com/demos/twitter">twitter demo</a> does.</p>
<p>We&#8217;ll look at using a proxy to get remote data in a future article.</p>
<h3>Remotely hosted javascript files</h3>
<p>Scripts stored on other websites can be included on a page. As long as the script doesn&#8217;t need to call home after the initial load, everything works great. This is how a basic twitter function works: you load a script from twitter&#8217;s website and it communicates with your site via the callback feature. This is what the Simple part of my <a href="http://nfriedly.com/demos/twitter">twitter demo</a> does.</p>
<p>Here is a very basic page that uses Twitter&#8217;s callback feature and a remotely loaded javascript file to show my twitter status &#8211; remote data &#8211; on my website, by interacting with local javascript.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;  dir=&quot;ltr&quot; lang=&quot;en-US&quot;&gt;

&lt;head&gt;
&lt;title&gt;Simple Twitter Status&lt;/title&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;h1&gt;My Twitter Status:&lt;/h1&gt;

&lt;div id=&quot;twitter_status&quot;&gt;Loading...&lt;/div&gt;

&lt;!-- Put scripts down here for speed --&gt;

&lt;!-- this must come before we load the twitter script --&gt;
&lt;script type=&quot;text/javascript&quot;&gt;

function showStatus(json){

	json = json[0]; // we only care about the most recent status;

	var myDiv = document.getElementById('twitter_status');

	myDiv.innerHTML = '&lt;img src=&quot;'
		+ json.user.profile_image_url
		+ '&quot; style=&quot;float:left; margin:5px 10px 10px 0&quot;&gt;'
		+ json.text;
}
&lt;/script&gt;

&lt;!-- now load the twitter file --&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://twitter.com/statuses/user_timeline/nfriedly.json?count=1&amp;amp;callback=showStatus&amp;amp;random=&lt;?php echo time(); ?&gt;&quot; /&gt;
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>You can see a live copy of this code at <a href="http://nfriedly.com/demos/twitter-extra-simple">http://nfriedly.com/demos/twitter-extra-simple</a>.</p>
<h2>Digging into Twitter&#8217;s callback method</h2>
<p>Below is a trimmed down example of what Twitter&#8217;s API sends back when we make the request in the example above.</p>
<pre class="brush: jscript; title: ; notranslate">
showStatus([{&quot;in_reply_to_screen_name&quot;:null,&quot;text&quot;:&quot; [ Lots of information that I'm omitting because it's not the point. ] &quot;]);
</pre>
<p>Now, don&#8217;t worry about the jazz in the middle, just look at that showStatus(); that&#8217;s wrapped around it. First of all, how does Twitter even know that we have a function named show status? Because we said so in the url to the file -see how we added <code>&amp;callback=showStatus</code>? That&#8217;s where the magic is.  (Ok, technically we said <code>&amp;amp;</code> not just <code>&amp;</code>, but that was just to pass XHTML validation. )</p>
<p><img class="alignright" title="The break!" src="http://www.sxc.hu/pic/m/l/lj/ljweb/490307_pool_break.jpg" alt="" width="300" height="168" /></p>
<h3>Cross-domain!</h3>
<p>There&#8217;s a second important thing going on here &#8211; javascript from two different domains are interacting with each other. This is allowed because of how the Same Origin Policy works &#8211; everything is restricted to the local domain, but that means that everything can work together on the same plane.</p>
<h3>It&#8217;s a beautiful thing</h3>
<p>I hope this gave you a little bit better understanding of how AJAX security works and how Twitter gets around it and is still able to interact with your site. In the future, I&#8217;ll have an article on how &#8220;traditional&#8221; callbacks work that will use jQuery and more AJAX to dive a bit deeper into the topic.</p>
<h2>Javascript Ninja for Hire</h2>
<p>I have <a href="http://nfriedly.com/portfolio">extensive experience</a> working with AJAX, Twitter, and related technologies. I&#8217;m just the man you need to make your next <a href="http://nfriedly.com/webdev">javascript development</a> project shine!</p>
]]></content:encoded>
			<wfw:commentRss>http://nfriedly.com/techblog/2009/06/javascript-security-ajax-json-and-twitter-callbacks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

