<?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>Wordpress API &#187; JSONP</title>
	<atom:link href="http://wordpressapi.com/category/javascript/jsonp/feed/" rel="self" type="application/rss+xml" />
	<link>http://wordpressapi.com</link>
	<description>Wordpress Tutorials, Tips, Code, Hacks, Themes, plugin, Developer Code book -Wordpress Code, Themes, Plugins, Tips, Tutorials, News, Releases, Designs, Hacks, Tricks, Blog</description>
	<lastBuildDate>Tue, 08 May 2012 17:37:16 +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>JSONP for cross domain communication solution using with javascript and PHP</title>
		<link>http://wordpressapi.com/2010/02/17/jsonp-cross-domain-communication-solution-javascript-php/</link>
		<comments>http://wordpressapi.com/2010/02/17/jsonp-cross-domain-communication-solution-javascript-php/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 11:48:45 +0000</pubDate>
		<dc:creator>Wordpress API</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JSONP]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[cross domain]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://images.wordpressapi.com/?p=1164</guid>
		<description><![CDATA[http://wordpressapi.com/2010/02/17/jsonp-cross-domain-communication-solution-javascript-php/Last year in Feb I heard about JSONP and really liked the JSONP solutions. JSONP allows you to make an HTTP request outside your own domain JSONP consume the Web Services from JavaScript code. Earlier I worked on so on &#8230; Continue reading &#8594;]]></description>
			<content:encoded><![CDATA[http://wordpressapi.com/2010/02/17/jsonp-cross-domain-communication-solution-javascript-php/<p>Last year in Feb I heard about JSONP and really liked the JSONP solutions. JSONP allows you to make an HTTP request outside your own domain<br />
JSONP consume the Web Services from JavaScript code. Earlier I worked on so on AJAX but there is issue with working or communication issue with cross domain sites.<br />
XMLHttpRequest is blocked from making external requests.</p>
<p>JavaScript code to make a JSONP call will as follows:</p>
<pre class="brush: jscript; title: ; notranslate">
function common_jsonpRequest(url, name, query) {

 if (url.indexOf(&quot;?&quot;) &gt; -1)
 url += &quot;&amp;jsonp=&quot;
 else
 url += name + &quot;&amp;&quot;;
 if (query)
 url += encodeURIComponent(query) + &quot;&amp;&quot;;
 url += new Date().getTime().toString(); // prevent caching

 var JSONPscript = document.createElement(&quot;script&quot;);
 JSONPscript.id = 'wordpressapi_jsonpRequest';
 JSONPscript.setAttribute(&quot;src&quot;, url + &quot;&amp;CacheBuster=&quot; + Math.random());
 JSONPscript.setAttribute(&quot;type&quot;,&quot;text/javascript&quot;);

 // write the jsonp script tag
 document.body.appendChild(JSONPscript);
 //script.text = &quot;&quot;;

}

function returncall (data){
 alert(data);
// you can use data as a variable also.
}
</pre>
<p>In same javascript you should write the returning function as above.</p>
<p>You can call JSONP this function as follows;</p>
<pre class="brush: jscript; title: ; notranslate">&lt;a href=&quot;http://images.wordpressapi.com/JSONP-request.gif&quot;&gt;&lt;img class=&quot;alignnone size-medium wp-image-1167&quot; title=&quot;JSONP-request&quot; src=&quot;http://images.wordpressapi.com/JSONP-request-300x125.gif&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;125&quot; /&gt;&lt;/a&gt;
common_jsonpRequest(base_url+'getData.php?jsonp=mycallback&amp;name=for_wordpressapi');
</pre>
</pre>
<p>Notel: getData.php file will beahave like externaal javascript file so handle this file carefully.<br />
getData.php sample file.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$data = &quot;this is our dynamic data&quot;;
if($_REQUEST['name']=='for_wordpressapi'){

echo &quot;returncall(&quot;.$data.&quot;)&quot;;

}

?&gt; </pre>
<p>This will return the "this is our dynamic data" as a alert.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://wordpressapi.com/2010/02/17/jsonp-cross-domain-communication-solution-javascript-php/" title="cross domain solutions in javascript">cross domain solutions in javascript</a></li><li><a href="http://wordpressapi.com/2010/02/17/jsonp-cross-domain-communication-solution-javascript-php/" title="cross site communications php">cross site communications php</a></li><li><a href="http://wordpressapi.com/2010/02/17/jsonp-cross-domain-communication-solution-javascript-php/" title="cross-domain communications with jsonp">cross-domain communications with jsonp</a></li><li><a href="http://wordpressapi.com/2010/02/17/jsonp-cross-domain-communication-solution-javascript-php/" title="javascript wordpress communication">javascript wordpress communication</a></li><li><a href="http://wordpressapi.com/2010/02/17/jsonp-cross-domain-communication-solution-javascript-php/" title="jsonp crossdomain php">jsonp crossdomain php</a></li><li><a href="http://wordpressapi.com/2010/02/17/jsonp-cross-domain-communication-solution-javascript-php/" title="jsonp php file">jsonp php file</a></li><li><a href="http://wordpressapi.com/2010/02/17/jsonp-cross-domain-communication-solution-javascript-php/" title="wordpress cross domain databases">wordpress cross domain databases</a></li></ul><p>Follow us on Twitter <a href="http://twitter.com/wordpressapi">WordPress API</a></p>]]></content:encoded>
			<wfw:commentRss>http://wordpressapi.com/2010/02/17/jsonp-cross-domain-communication-solution-javascript-php/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: wordpressapi.com @ 2012-05-23 02:22:26 by W3 Total Cache -->
