<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Designing a JavaScript client for a REST API</title>
	<atom:link href="http://ajaxian.com/archives/designing-a-javascript-client-for-a-rest-api/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/designing-a-javascript-client-for-a-rest-api</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 17 May 2012 07:43:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: shadedecho</title>
		<link>http://ajaxian.com/archives/designing-a-javascript-client-for-a-rest-api/comment-page-1#comment-271414</link>
		<dc:creator>shadedecho</dc:creator>
		<pubDate>Tue, 17 Feb 2009 21:27:14 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=5969#comment-271414</guid>
		<description>@jared-understood, the flash &quot;barrier&quot; is not something so trivial as to not think about or take for granted.  Not to hijack this thread too much, but to address your flash concern, I did have a couple of thoughts (as I&#039;m very opinionated and passionate about this particular topic).
.
With *so* much flash out there, and with Adobe reporting numbers in excess of 99% global penetration, and with those same numbers even showing *huge* (&gt;50% over 3 months) rates of adoption of their latest 10.x plugin version, I think we&#039;re getting to the point where flash is arguably a ubiquitous technology. It is certainly more ubiquitous than Java, Silverlight, or even any one single browser.
.
And, in the same way that you need to provide a &quot;graceful degradation&quot; (or, depending on your perspective, &quot;graceful enhancement&quot;) for those with or without javascript support (etc), I think the same can be true of flXHR and flash based solutions.
.
For instance, you can use the underlying javascript toolset (CheckPlayer, built on top of SWFObject) to easily upfront detect if flash is enabled for the end-user, and of the right version, and then fork your logic at that point to handle it however you see fit.
.
One way (what I think is the best user experience) is to use Adobe&#039;s express-install (which flXHR fully exposes) to automatically and in-line, in the same browser page/instance, provide users a way to update flash as necessary. With well over 99% of people on the internet having *some* flash installed, that&#039;s an incredibly high number of people that will be able to simply upgrade their plugin and use your site as you intended with minimal user-experience impact.
.
On the other hand, you could have that same flash (version) detection logic simply decide that if they don&#039;t have the flash installed, then dynamically you load a simple &quot;shim&quot; script like the one for doing the dynamic-script-tags, or another one which does dynamic iframes, to take the place of flXHR.
.
If you choose/design that &quot;shim&quot; in the right way (that is, with a compatible API to normal native XHR, like flXHR did), or at least some wrapper thereof, it&#039;ll br a graceful fallback for non-flash users and the rest of your code logic is happily unaware.
.
The reason I advocate choosing flash (flXHR) as the primary (rather than fallback) method is that there are important benefits to be gained in terms of security (the full server policy model leveraging) and efficiency (one small flash instance as opposed to several memory-hogging invisible iframe instances). Also, the communication part of flXHR uses no timers (or ugly JSONP callbacks), so in general it should be quicker and more direct to get data to and from the server. In performance tests, it performed admirably and competively with several other various popular cross-domain solutions.
.
My point is, a few years ago, the argument against flash as mission critical app technology was compelling. But nowadays, I think it&#039;s much less so, and really it&#039;s only a few stalwart holdouts who refuse to embrace the parts of flash that can genuinely be helpful in UI technology and better UX.</description>
		<content:encoded><![CDATA[<p>@jared-understood, the flash &#8220;barrier&#8221; is not something so trivial as to not think about or take for granted.  Not to hijack this thread too much, but to address your flash concern, I did have a couple of thoughts (as I&#8217;m very opinionated and passionate about this particular topic).<br />
.<br />
With *so* much flash out there, and with Adobe reporting numbers in excess of 99% global penetration, and with those same numbers even showing *huge* (&gt;50% over 3 months) rates of adoption of their latest 10.x plugin version, I think we&#8217;re getting to the point where flash is arguably a ubiquitous technology. It is certainly more ubiquitous than Java, Silverlight, or even any one single browser.<br />
.<br />
And, in the same way that you need to provide a &#8220;graceful degradation&#8221; (or, depending on your perspective, &#8220;graceful enhancement&#8221;) for those with or without javascript support (etc), I think the same can be true of flXHR and flash based solutions.<br />
.<br />
For instance, you can use the underlying javascript toolset (CheckPlayer, built on top of SWFObject) to easily upfront detect if flash is enabled for the end-user, and of the right version, and then fork your logic at that point to handle it however you see fit.<br />
.<br />
One way (what I think is the best user experience) is to use Adobe&#8217;s express-install (which flXHR fully exposes) to automatically and in-line, in the same browser page/instance, provide users a way to update flash as necessary. With well over 99% of people on the internet having *some* flash installed, that&#8217;s an incredibly high number of people that will be able to simply upgrade their plugin and use your site as you intended with minimal user-experience impact.<br />
.<br />
On the other hand, you could have that same flash (version) detection logic simply decide that if they don&#8217;t have the flash installed, then dynamically you load a simple &#8220;shim&#8221; script like the one for doing the dynamic-script-tags, or another one which does dynamic iframes, to take the place of flXHR.<br />
.<br />
If you choose/design that &#8220;shim&#8221; in the right way (that is, with a compatible API to normal native XHR, like flXHR did), or at least some wrapper thereof, it&#8217;ll br a graceful fallback for non-flash users and the rest of your code logic is happily unaware.<br />
.<br />
The reason I advocate choosing flash (flXHR) as the primary (rather than fallback) method is that there are important benefits to be gained in terms of security (the full server policy model leveraging) and efficiency (one small flash instance as opposed to several memory-hogging invisible iframe instances). Also, the communication part of flXHR uses no timers (or ugly JSONP callbacks), so in general it should be quicker and more direct to get data to and from the server. In performance tests, it performed admirably and competively with several other various popular cross-domain solutions.<br />
.<br />
My point is, a few years ago, the argument against flash as mission critical app technology was compelling. But nowadays, I think it&#8217;s much less so, and really it&#8217;s only a few stalwart holdouts who refuse to embrace the parts of flash that can genuinely be helpful in UI technology and better UX.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shadedecho</title>
		<link>http://ajaxian.com/archives/designing-a-javascript-client-for-a-rest-api/comment-page-1#comment-271405</link>
		<dc:creator>shadedecho</dc:creator>
		<pubDate>Tue, 17 Feb 2009 15:51:03 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=5969#comment-271405</guid>
		<description>Another option for the cross-domain XHR, if you don&#039;t want to hack around with a bunch of timers and iframe creation (very memory intensive and time consuming for clients) is to use flXHR [ http://flxhr.flensed.com/ ] which is a javascript+flash re-implementation of the identical native XHR object&#039;s API, but since it uses an invisible flash component, it can make cross-domain calls if the server opt-in policy allows it. Since the API is identical, flXHR drops in as a simple replacement without *any* futher coding changes, even with frameworks and existing code that know how to speak to an XHR object.</description>
		<content:encoded><![CDATA[<p>Another option for the cross-domain XHR, if you don&#8217;t want to hack around with a bunch of timers and iframe creation (very memory intensive and time consuming for clients) is to use flXHR [ <a href="http://flxhr.flensed.com/" rel="nofollow">http://flxhr.flensed.com/</a> ] which is a javascript+flash re-implementation of the identical native XHR object&#8217;s API, but since it uses an invisible flash component, it can make cross-domain calls if the server opt-in policy allows it. Since the API is identical, flXHR drops in as a simple replacement without *any* futher coding changes, even with frameworks and existing code that know how to speak to an XHR object.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: loveencounterflow</title>
		<link>http://ajaxian.com/archives/designing-a-javascript-client-for-a-rest-api/comment-page-1#comment-271404</link>
		<dc:creator>loveencounterflow</dc:creator>
		<pubDate>Tue, 17 Feb 2009 15:28:42 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=5969#comment-271404</guid>
		<description>more to the point: &quot;&quot;&quot;For HTTP methods other than GET (e.g. HEAD, POST, PUT, DELETE), script transport would require disguising the request as a GET, which has different semantics. Then there’s also the fact that a large request might not fit into a single URL. There must be a better alternative.&quot;&quot;&quot;---YES, there is a better alternative. do not disguise a DELETE request as a GET request. just cut it out. you want to DELETE http://example.com/product/42 ? fine. goto http://example.com/delete/product/42 and you&#039;ll be fine. 
.
while we&#039;re at it: RESTfolks always try to sell DELETE and PUT---what if i want to BUY product/42? will i have to issue an HTTP BUY request to http://example.com/product/42 ? what if it&#039;s time to checkout? do i have to issue an HTTP CHECKOUT to http://example.com/shop ? what if i want to pay? issue HTTP PAY http://example.com/cashregister/$7.00 ?? 
.
this is hilarious.</description>
		<content:encoded><![CDATA[<p>more to the point: &#8220;&#8221;"For HTTP methods other than GET (e.g. HEAD, POST, PUT, DELETE), script transport would require disguising the request as a GET, which has different semantics. Then there’s also the fact that a large request might not fit into a single URL. There must be a better alternative.&#8221;"&#8221;&#8212;YES, there is a better alternative. do not disguise a DELETE request as a GET request. just cut it out. you want to DELETE <a href="http://example.com/product/42" rel="nofollow">http://example.com/product/42</a> ? fine. goto <a href="http://example.com/delete/product/42" rel="nofollow">http://example.com/delete/product/42</a> and you&#8217;ll be fine.<br />
.<br />
while we&#8217;re at it: RESTfolks always try to sell DELETE and PUT&#8212;what if i want to BUY product/42? will i have to issue an HTTP BUY request to <a href="http://example.com/product/42" rel="nofollow">http://example.com/product/42</a> ? what if it&#8217;s time to checkout? do i have to issue an HTTP CHECKOUT to <a href="http://example.com/shop" rel="nofollow">http://example.com/shop</a> ? what if i want to pay? issue HTTP PAY <a href="http://example.com/cashregister/$7.00" rel="nofollow">http://example.com/cashregister/$7.00</a> ??<br />
.<br />
this is hilarious.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: loveencounterflow</title>
		<link>http://ajaxian.com/archives/designing-a-javascript-client-for-a-rest-api/comment-page-1#comment-271403</link>
		<dc:creator>loveencounterflow</dc:creator>
		<pubDate>Tue, 17 Feb 2009 15:21:12 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=5969#comment-271403</guid>
		<description>this is an excerpt on the topic of &quot;CRUD&quot;-style RESTful interfaces; originally posted to http://jjinux.blogspot.com/2009/02/rest-restful-shopping-carts.html
where you can also read a nice discussion on the subject.
.
i’ve said it before, and i’ll say it again, 10³ times if necessary: if RESTful means you go from GET and POST to GET, POST, PUT, DELETE---then it’s a bad idea.
.
RESTful thinking is a great tool to clear up in your mind essential principles of the way the web works. GET, POST, PUT, DELETE are not so hot. GET and POST are great, they are what is actually implemented in browsers, and they’re sufficient. to put CRUD (Create, read, update and delete) into the HTTP method is bad.
.
any semantics that go beyond the ‘underlying request modalities’ of HTTP communication do NOT belong into the HTTP method, they belong into the URL. One very obvious piece of evidence to corroborate this is the fact that in a RESTful app, you cannot specify both your object and your intent in one URL. 
.
that there are even more HTTP ‘verbs’---HEAD, TRACE, OPTIONS, CONNECT---that are not really talked about within the RESThype makes me suspicious. i want to argue that just as there are HTTP methods that are seldomly used (at least not by clients, only under the hood), so there are HTTP methods that got designed once, but are as superfluous as e.g. the POP and the FTP protocols (they got invented when HTTP was less prevailant than today---one protocol for a single purpose. they can’t do anything that HTTP can’t do).

DELETE and PUT are just as obsolete as the [font/] tag---they looked like a good idea at the time, and when they got replaced by something (much) better, no-one looked back.</description>
		<content:encoded><![CDATA[<p>this is an excerpt on the topic of &#8220;CRUD&#8221;-style RESTful interfaces; originally posted to <a href="http://jjinux.blogspot.com/2009/02/rest-restful-shopping-carts.html" rel="nofollow">http://jjinux.blogspot.com/2009/02/rest-restful-shopping-carts.html</a><br />
where you can also read a nice discussion on the subject.<br />
.<br />
i’ve said it before, and i’ll say it again, 10³ times if necessary: if RESTful means you go from GET and POST to GET, POST, PUT, DELETE&#8212;then it’s a bad idea.<br />
.<br />
RESTful thinking is a great tool to clear up in your mind essential principles of the way the web works. GET, POST, PUT, DELETE are not so hot. GET and POST are great, they are what is actually implemented in browsers, and they’re sufficient. to put CRUD (Create, read, update and delete) into the HTTP method is bad.<br />
.<br />
any semantics that go beyond the ‘underlying request modalities’ of HTTP communication do NOT belong into the HTTP method, they belong into the URL. One very obvious piece of evidence to corroborate this is the fact that in a RESTful app, you cannot specify both your object and your intent in one URL.<br />
.<br />
that there are even more HTTP ‘verbs’&#8212;HEAD, TRACE, OPTIONS, CONNECT&#8212;that are not really talked about within the RESThype makes me suspicious. i want to argue that just as there are HTTP methods that are seldomly used (at least not by clients, only under the hood), so there are HTTP methods that got designed once, but are as superfluous as e.g. the POP and the FTP protocols (they got invented when HTTP was less prevailant than today&#8212;one protocol for a single purpose. they can’t do anything that HTTP can’t do).</p>
<p>DELETE and PUT are just as obsolete as the [font/] tag&#8212;they looked like a good idea at the time, and when they got replaced by something (much) better, no-one looked back.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: halans</title>
		<link>http://ajaxian.com/archives/designing-a-javascript-client-for-a-rest-api/comment-page-1#comment-271394</link>
		<dc:creator>halans</dc:creator>
		<pubDate>Mon, 16 Feb 2009 21:51:28 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=5969#comment-271394</guid>
		<description>Great article!
Same could apply to developing bookmarklets, like (warning, blatant self promotion coming up) my own http://www.mapanui.com , which could use some improvements, like what you described here.</description>
		<content:encoded><![CDATA[<p>Great article!<br />
Same could apply to developing bookmarklets, like (warning, blatant self promotion coming up) my own <a href="http://www.mapanui.com" rel="nofollow">http://www.mapanui.com</a> , which could use some improvements, like what you described here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: EdSpencer</title>
		<link>http://ajaxian.com/archives/designing-a-javascript-client-for-a-rest-api/comment-page-1#comment-271393</link>
		<dc:creator>EdSpencer</dc:creator>
		<pubDate>Mon, 16 Feb 2009 20:32:36 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=5969#comment-271393</guid>
		<description>Excellent article.

Talking to other domains is a pain point I&#039;ve been fortunate enough to avoid so far but I&#039;ll refer back to this when my luck runs out.  Thanks!</description>
		<content:encoded><![CDATA[<p>Excellent article.</p>
<p>Talking to other domains is a pain point I&#8217;ve been fortunate enough to avoid so far but I&#8217;ll refer back to this when my luck runs out.  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vikingstad</title>
		<link>http://ajaxian.com/archives/designing-a-javascript-client-for-a-rest-api/comment-page-1#comment-271390</link>
		<dc:creator>vikingstad</dc:creator>
		<pubDate>Mon, 16 Feb 2009 16:24:40 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=5969#comment-271390</guid>
		<description>JSONP doesn&#039;t necessarily require a proxy, that is completely up to whoever implements it.</description>
		<content:encoded><![CDATA[<p>JSONP doesn&#8217;t necessarily require a proxy, that is completely up to whoever implements it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Mahemoff</title>
		<link>http://ajaxian.com/archives/designing-a-javascript-client-for-a-rest-api/comment-page-1#comment-271389</link>
		<dc:creator>Michael Mahemoff</dc:creator>
		<pubDate>Mon, 16 Feb 2009 14:40:03 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=5969#comment-271389</guid>
		<description>See also http://softwareas.com/cross-domain-communication-with-iframes - there are some basic demos of both the approaches described here (&quot;URL polling&quot; and &quot;Marathon&quot;).</description>
		<content:encoded><![CDATA[<p>See also <a href="http://softwareas.com/cross-domain-communication-with-iframes" rel="nofollow">http://softwareas.com/cross-domain-communication-with-iframes</a> &#8211; there are some basic demos of both the approaches described here (&#8220;URL polling&#8221; and &#8220;Marathon&#8221;).</p>
]]></content:encoded>
	</item>
</channel>
</rss>

