<?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 &#187; javascript</title>
	<atom:link href="http://www.drawloop.com/blog/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.drawloop.com</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Thu, 17 May 2012 21:24:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Cross-Site Ajax</title>
		<link>http://www.drawloop.com/blog/2007/09/17/cross-site-ajax/</link>
		<comments>http://www.drawloop.com/blog/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 as [...]]]></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 <script> 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><script src="page?field1=value1&amp;callback=functionName" type="text/javascript"></script></p>
</blockquote>
<p>What this does is makes a get request to "page" 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('data you want to return');</p>
</blockquote>
<p>The functionName just needs to be a function you write to handle whatever you're expecting as a return from the page.<!--more--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.drawloop.com/blog/2007/09/17/cross-site-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 19/24 queries in 0.094 seconds using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: dzwcomtqyhdt6.cloudfront.net

Served from: www.drawloop.com @ 2012-05-21 14:15:59 -->
