<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: alternative to XMLHttpRequest</title>
	<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest/</link>
	<description>Comments on Ask MetaFilter post alternative to XMLHttpRequest</description>
	<pubDate>Sun, 12 Mar 2006 17:50:16 -0800</pubDate>
	<lastBuildDate>Sun, 12 Mar 2006 17:50:16 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: alternative to XMLHttpRequest</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest</link>	
		<description>Is there an alternative to XMLHttpRequest that would work across different domains? &lt;br /&gt;&lt;br /&gt; I&apos;m working on an &quot;external voting button&quot;  similar the one on Digg, that submits to the server without actually having to leave the page.  I want to run it so that external sites can use it to submit back to the mother server.  The problem I&apos;ve run into is the security restriction with XMLHttpRequest, in that it will only submit back to the domain name that the current page is actually hosted by.  Is there a way around this?  &lt;br&gt;
&lt;br&gt;
I found &lt;a href http://ajaxextended.com/&gt;this&lt;/a&gt; but I&apos;m not sure exactly what he&apos;s doing, or what &quot;dynamic script tags&quot; are.</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2006:site.34210</guid>
		<pubDate>Sun, 12 Mar 2006 17:47:44 -0800</pubDate>
		<dc:creator>Dag Maggot</dc:creator>
		
			<category>ajax</category>
		
			<category>javascript</category>
		
			<category>webdevelopment</category>
		
	</item> <item>
		<title>By: jaded</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#533809</link>	
		<description>While my knowledge of javascript and things ajaxy is somewhat limited, I&apos;m pretty sure not.&lt;br&gt;
&lt;br&gt;
BUT - this sort of thing is fairly trivial using a server side language like PHP. If your XMLHttpRequest calls a php script that fetches data from somewhere else, that should work.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-533809</guid>
		<pubDate>Sun, 12 Mar 2006 17:50:16 -0800</pubDate>
		<dc:creator>jaded</dc:creator>
	</item><item>
		<title>By: Rhomboid</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#533824</link>	
		<description>&lt;small&gt;Your link is malformed, it looks like you meant to link to &lt;a href=&quot;http://ajaxextended.com/&quot;&gt;here&lt;/a&gt;.&lt;/small&gt;&lt;br&gt;
&lt;br&gt;
Can you create a hidden IFRAME and load the external URL there?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-533824</guid>
		<pubDate>Sun, 12 Mar 2006 18:07:10 -0800</pubDate>
		<dc:creator>Rhomboid</dc:creator>
	</item><item>
		<title>By: Dag Maggot</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#533826</link>	
		<description>yes, thanks for the link fix.    Doesn&apos;t an Iframe like that have the same problem?  Has to be from the same domain or a pop-up ensures?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-533826</guid>
		<pubDate>Sun, 12 Mar 2006 18:09:59 -0800</pubDate>
		<dc:creator>Dag Maggot</dc:creator>
	</item><item>
		<title>By: delmoi</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#533832</link>	
		<description>Yeah, simplest thing is just to load the URL inside your PHP script on the server.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-533832</guid>
		<pubDate>Sun, 12 Mar 2006 18:15:58 -0800</pubDate>
		<dc:creator>delmoi</dc:creator>
	</item><item>
		<title>By: Dag Maggot</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#533854</link>	
		<description>Well see, the problem I&apos;m having, is that I need to avoid a server side solution, because I want to give users the ability to drop a small javascript into their blog and have it just work, just like Technorati, or a google adword. &lt;br&gt;
&lt;br&gt;
That&apos;s where the cross domain security lockdown of XMLHttpRequest stumps me.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-533854</guid>
		<pubDate>Sun, 12 Mar 2006 18:39:10 -0800</pubDate>
		<dc:creator>Dag Maggot</dc:creator>
	</item><item>
		<title>By: IshmaelGraves</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#533866</link>	
		<description>Could you have the link/button/whatever itself in an IFRAME, which loaded a page on your server to display the button? Such that the XMLHttpRequest was made from within the IFRAME and thus to the same server? I don&apos;t know whether this would work.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-533866</guid>
		<pubDate>Sun, 12 Mar 2006 18:57:11 -0800</pubDate>
		<dc:creator>IshmaelGraves</dc:creator>
	</item><item>
		<title>By: Rhomboid</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#533867</link>	
		<description>I could be wrong but I don&apos;t think you&apos;ll run into cross-domain problems with an IFRAME.  Certainly, if you load a page from an unrelated domain in a frame it should not have access to the cookies, DOM, and so on of the parent, so you can&apos;t interact between the two.  But it seems to me that the point here is just to &quot;hit&quot; a URL, not to necessarily do anything with the results, and in that sense an IFRAME should work fine.  If they didn&apos;t allow this then I think a whole lot of advertising would break, since those seem to be on radically different domains.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-533867</guid>
		<pubDate>Sun, 12 Mar 2006 18:57:23 -0800</pubDate>
		<dc:creator>Rhomboid</dc:creator>
	</item><item>
		<title>By: Dag Maggot</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#533869</link>	
		<description>OK, thanks, I will give that a try, I thought that iFrames were restrictive in this way, but I&apos;ll have a play.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-533869</guid>
		<pubDate>Sun, 12 Mar 2006 19:01:25 -0800</pubDate>
		<dc:creator>Dag Maggot</dc:creator>
	</item><item>
		<title>By: null terminated</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#533871</link>	
		<description>You can include javascript remotely.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-533871</guid>
		<pubDate>Sun, 12 Mar 2006 19:01:54 -0800</pubDate>
		<dc:creator>null terminated</dc:creator>
	</item><item>
		<title>By: SNACKeR</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#533878</link>	
		<description>You shouldn&apos;t need an IFRAME, just set the src on a hidden IMG tag to your url, with the data as querystring params.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-533878</guid>
		<pubDate>Sun, 12 Mar 2006 19:20:59 -0800</pubDate>
		<dc:creator>SNACKeR</dc:creator>
	</item><item>
		<title>By: Dag Maggot</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#533891</link>	
		<description>Good idea Snacker, but I want this to be a button, and not to send the variables until clicked (not on page load).</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-533891</guid>
		<pubDate>Sun, 12 Mar 2006 19:45:10 -0800</pubDate>
		<dc:creator>Dag Maggot</dc:creator>
	</item><item>
		<title>By: mmascolino</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#533894</link>	
		<description>what if you host the javascript file on your mothership server, and have them reference that file to be included into their pages.  This is much like how including Google Adsense into a website works.  I am not 100% sure that this gets around cross domain security issues, but it might be something worthwhile to try.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-533894</guid>
		<pubDate>Sun, 12 Mar 2006 20:08:30 -0800</pubDate>
		<dc:creator>mmascolino</dc:creator>
	</item><item>
		<title>By: IshmaelGraves</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#533896</link>	
		<description>Building on Snacker&apos;s idea, if you&apos;re not concerned with getting a response from the server, could you try a button with an onClick method which replaces its SRC attribute with one that contains the relevant URL parameters?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-533896</guid>
		<pubDate>Sun, 12 Mar 2006 20:14:40 -0800</pubDate>
		<dc:creator>IshmaelGraves</dc:creator>
	</item><item>
		<title>By: nielm</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#534004</link>	
		<description>Simple solution -- If you only need a success/fail response, load an image from the voting server with JS:&lt;br&gt;
In the onClick method, create a new Image, and load the, where the URL of the image is the php voting script on the other server -- and get this script to return a dummy 1x1 image.&lt;br&gt;
&lt;br&gt;
eg:&lt;br&gt;
&lt;tt&gt;&lt;br&gt;
voteurl=&quot;http://voting.server.site/path/to/voting_script.php?vote=voting_args&quot;;&lt;br&gt;
/* Disable voting button here, and set it to a &apos;submitting&apos; image to avoid mutliple clicks */&lt;br&gt;
CmdImage=new Image();&lt;br&gt;
CmdImage.onload=new Function(&apos;Some_js_to_modify_voting_button_to_indicate_successful_voting&apos;);&lt;br&gt;
CmdImage.onerror=new Function(&apos;window.location=&quot;&apos;+voteurl+&apos;&quot;;&apos;);&lt;br&gt;
/* load the image / submit the vote */&lt;br&gt;
CmdImage.src=voteurl+&quot;&amp;amp;returnImage=true&quot;;&lt;br&gt;
&lt;/tt&gt;&lt;br&gt;
&lt;br&gt;
The onerror action is to handle failures: resubmit the same vote, but this time load the entire page so that any errors can be displayed.&lt;br&gt;
&lt;br&gt;
Also make sure that the voting script sets all the appropriate expires/nocache headers so that the returned image does not get cached.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-534004</guid>
		<pubDate>Mon, 13 Mar 2006 02:49:00 -0800</pubDate>
		<dc:creator>nielm</dc:creator>
	</item><item>
		<title>By: nielm</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#534005</link>	
		<description>Just realised, this is like  IshmaelGraves solution :)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-534005</guid>
		<pubDate>Mon, 13 Mar 2006 02:49:41 -0800</pubDate>
		<dc:creator>nielm</dc:creator>
	</item><item>
		<title>By: nicwolff</title>
		<link>http://ask.metafilter.com/34210/alternative-to-XMLHttpRequest#556466</link>	
		<description>&lt;i&gt;Also make sure that the voting script sets all the appropriate expires/nocache headers so that the returned image does not get cached.&lt;/i&gt;&lt;br&gt;
&lt;br&gt;
Or, just add a random argument to the call, like&lt;br&gt;
&lt;br&gt;
&lt;code&gt;CmdImage.src=voteurl+&quot;&amp;amp;returnImage=true&amp;amp;rand=&quot;+Math.random();&lt;/code&gt;&lt;br&gt;
&amp;nbsp;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.34210-556466</guid>
		<pubDate>Wed, 05 Apr 2006 16:52:45 -0800</pubDate>
		<dc:creator>nicwolff</dc:creator>
	</item>
	</channel>
</rss>
