<?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>Developer Code book &#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>Wordpressapi.com is focused on Wordpress API, wordpress news, wordpress themes, wordpress plugins, wordpress tips, wordpress tutorials, wordpress design wordpress templates, wordpress breaking news and web-development. We deliver useful information about wordpress,  wordpress latest trends and wordpress techniques, wordpress useful ideas, wordpress innovative approaches and wordpress tools. Social Media news blog covering cool new websites and social networks: Facebook, Google, Twitter, MySpace and YouTube.  The latest web technology news, via RSS daily.</description> <lastBuildDate>Sun, 05 Sep 2010 06:21:54 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.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>Sony</dc:creator> <category><![CDATA[JSONP]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[XML]]></category> <category><![CDATA[Ajax]]></category> <category><![CDATA[communication]]></category> <category><![CDATA[cross domain]]></category> <category><![CDATA[xml]]></category><guid
isPermaLink="false">http://wordpressapi.com/?p=1164</guid> <description><![CDATA[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 AJAX but there is issue with working or communication issue with cross domain sites. XMLHttpRequest.....]]></description> <content:encoded><![CDATA[<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;">
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;">&lt;a href=&quot;http://wordpressapi.com/files/JSONP-request.gif&quot;&gt;&lt;img class=&quot;alignnone size-medium wp-image-1167&quot; title=&quot;JSONP-request&quot; src=&quot;http://wordpressapi.com/files/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;">
&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> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2010/02/17/jsonp-cross-domain-communication-solution-javascript-php/feed/</wfw:commentRss> <slash:comments>10</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching 19/31 queries in 0.080 seconds using disk

Served from: wordpressapi.com @ 2010-09-07 13:27:06 -->