jquery ajax to retrieve JSON data from remote URL

1

test.json

<script type="text/javascript"> function getJSON(json) { alert("Got JSON!"); // do something with json } </script> <script type="text/javascript" src="http://192.168.99.68/test.json?callback=getJSON" async="true"></script>

2

<div id="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 ) return false; }); });

3

$.jsonp({ "url": target_url+"ping.php?callback=?", "success": function(data) { // print out data }, "error": function(d,msg) { // error } });
<?php echo $_GET['callback'] . '(' . "{'response' : 'success'}" . ')'; ?>

https://github.com/jaubourg/jquery-jsonp