jquery ajax to retrieve JSON data from remote URL
1
test.json
<scripttype="text/javascript"> function getJSON(json) { alert("Got JSON!"); // do something with json } </script><scripttype="text/javascript"src="http://192.168.99.68/test.json?callback=getJSON" async="true"></script>
2
<divid="images"> </div>
$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",{ tags:"gulmarg", tagmode:"any", format:"json"},function(data){ $.each(data.items,function(i,item){ $("<img/>").attr("src", item.media.m).appendTo("#images");if( i ==5)returnfalse;});});
3
$.jsonp({"url": target_url+"ping.php?callback=?","success":function(data){// print out data},"error":function(d,msg){// error}});
<?phpecho$_GET['callback'].'('."{'response' : 'success'}".')';?>