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 is blocked from making external requests.
JavaScript code to make a JSONP call will as follows:
function common_jsonpRequest(url, name, query) {
if (url.indexOf("?") > -1)
url += "&jsonp="
else
url += name + "&";
if (query)
url += encodeURIComponent(query) + "&";
url += new Date().getTime().toString(); // prevent caching
var JSONPscript = document.createElement("script");
JSONPscript.id = 'wordpressapi_jsonpRequest';
JSONPscript.setAttribute("src", url + "&CacheBuster=" + Math.random());
JSONPscript.setAttribute("type","text/javascript");
// write the jsonp script tag
document.body.appendChild(JSONPscript);
//script.text = "";
}
function returncall (data){
alert(data);
// you can use data as a variable also.
}
In same javascript you should write the returning function as above.
You can call JSONP this function as follows;
<a href="http://images.wordpressapi.com/JSONP-request.gif"><img class="alignnone size-medium wp-image-1167" title="JSONP-request" src="http://images.wordpressapi.com/JSONP-request-300x125.gif" alt="" width="300" height="125" /></a> common_jsonpRequest(base_url+'getData.php?jsonp=mycallback&name=for_wordpressapi');
Notel: getData.php file will beahave like externaal javascript file so handle this file carefully.
getData.php sample file.
<?php
$data = "this is our dynamic data";
if($_REQUEST['name']=='for_wordpressapi'){
echo "returncall(".$data.")";
}
?>
This will return the "this is our dynamic data" as a alert.
Incoming search terms:
- cross domain communication jsonp
- jsonp request image
- google adsense kind of solution cross domain ajavscript
- cross domain communication javascript
- php javascript communication
- jsonp xml cross
- jsonp post file upload
- jsonp images
- JSONP cross domain
- json-p wordpress
- cross-domain communications with jsonp
- cross-Domain Communication JSONP
- cross domain registration wordpress
- stackoverflow nginx directory index forbidden



very cool & good tip, thank you very much for sharing
This article is very important to me, and I like it very much, I will add it to my favorites.
this is a really good resource for educators. thanks for sharing.
I don’t know why I clicked on the link to your blog, but I’m glad I did. Fine and dandy post! Please keep writing more.
Exceptional webpage. My class mates and I were just discussing this the other night. Also your webpage looks great on my old laptop. Now thats uncommon. Nice work.
Super-Duper site! I am loving it!! Will come back again – taking you feeds also, Appreciation.
You made some good points there. I did a search on the topic and found most people will agree with
Wow dude, this is really helpful information, much appreciated.
In one moment in my search, I find your site, and always return for here because enjoy it.
I don’t normally post to blogs but I enjoyed this post so keep up the good work.
Will JSONP improve SEO?
See a more detailed version of my question here:
http://stackoverflow.com/questions/3764152/if-i-allow-partner-sites-to-republish-my-rss-feed-will-that-boost-my-seo-ranking
I also show how I implemented it, but I really want to know if it will help SEO.
Thanks!
Matt