<?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>Drawloop Blog &#187; ajax</title>
	<atom:link href="http://blog.drawloop.com/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.drawloop.com</link>
	<description>Automate Document Creation On-Demand</description>
	<lastBuildDate>Thu, 29 Jul 2010 17:30:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Cross-Site Ajax</title>
		<link>http://blog.drawloop.com/2007/09/17/cross-site-ajax/</link>
		<comments>http://blog.drawloop.com/2007/09/17/cross-site-ajax/#comments</comments>
		<pubDate>Mon, 17 Sep 2007 19:15:56 +0000</pubDate>
		<dc:creator>drawloop</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blog.drawloop.com/2007/09/17/cross-site-ajax/</guid>
		<description><![CDATA[Last week we ran into a problem trying to call a page with an XMLHttpRequest from one domain to another.
The situation was odd.  We weren&#8217;t trying to call another domain from our domain, we were trying to make a call to our domain from another domain.  Within Salesforce&#8217;s CRM, there&#8217;s a component known [...]]]></description>
			<content:encoded><![CDATA[<p>Last week we ran into a problem trying to call a page with an XMLHttpRequest from one domain to another.</p>
<p>The situation was odd.  We weren&#8217;t trying to call another domain from our domain, we were trying to make a call to our domain from another domain.  Within Salesforce&#8217;s CRM, there&#8217;s a component known as an SControl.  This component is an HTML page with accompanying Javascript used to create a custom interface within Salesforce.</p>
<p><span id="more-26"></span>After asking for various inputs, we wanted to send those to our own domain for processing, and spit back a response.  Our first thought was to use a simple XMLHttpRequest to do the post.  We use jQuery within that, and so it should have been as simple as:</p>
<blockquote><p>$.post(&#8220;url&#8221;, params, function(data){});</p></blockquote>
<p>Unfortunately, what I forgot was domain security. As I said above, this didn&#8217;t work at all.</p>
<p>I found our solution at <a href="http://www.sitepoint.com/articlelist/48" target="_blank">Kevin Yank&#8217;s blog</a> with an entry about <a href="http://www.sitepoint.com/blogs/2006/07/28/oscon-2006-cross-site-ajax/" target="_blank">OSCON 2006</a>.  The basic idea is to dynamically insert a &lt;script&gt; tag to handle your cross site code.  This works because script tags can load code from different domains.</p>
<p>Our final solution looks something like this:</p>
<blockquote><p>&lt;script src=&#8221;page?field1=value1&amp;callback=functionName&#8221; type=&#8221;text/javascript&#8221;&gt;&lt;/script&gt;</p></blockquote>
<p>What this does is makes a get request to &#8220;page&#8221; passing along the form variables that we previously wanted to post in the querystring.  The page then returns something that looks like:</p>
<blockquote><p>functionName(&#8216;data you want to return&#8217;);</p></blockquote>
<p>The functionName just needs to be a function you write to handle whatever you&#8217;re expecting as a return from the page.<!--more--></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.drawloop.com/2007/09/17/cross-site-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
