Question: In continuation to my question asked [here](https://stackoverflow.com/questions/4212105/how-to-get-and-display-the-list-of-youtube-videos-using-javascript), i have created a test app to check the json parsing using jquery. 
It doesnt seem to work. I can append data in the click function. However getting data from that url and parsing seems to fail. Can someone provide some useful hints?

```
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("button").click(function(){
    $("body").append("<div id = 'data'><ul>jffnfjnkj</ul></div>");
    $.getJSON("http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?callback=function&alt=jsonc&v=2", function(data) {
        var dataContainer = $("#data ul");
        $.each(data.data.items, function(i, val) {
         $("body").append("<div id = 'data'><ul>jffnfjnkj</ul></div>");
if (typeof(val.player) !== 'undefined' && typeof(val.title) !== 'undefined') {
dataContainer.append("<li><a href = "+val.player.default+" target = '_blank'>"+val.title+"</a></li>");
        }
        });
        });

  });
});
</script>
</head>

<body>
<h2>Header</h2>
<p>Paragrapgh</p>
<p>Paragraph.</p>
<button>Click me</button>
</body>
</html>

```

TIA,
Praveen S

Answer: 
The callback is provided so that you can bypass the same origin policy. Thus retrieved JSON data is enclosed within the function name and cannot be parsed directly. Details of doing this with jquery are given [here](http://api.jquery.com/jQuery.ajax/). Please refer the example given below

```
<script>
 $.ajax({
         url:'http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?alt=jsonc&v=2&callback=?',
         dataType: "jsonp",
         timeout: 5000,
         success: function(data){
                    alert(data.apiVersion);
                    //add your JSON parsing code here
                  }

 });

</script>

```

Please find the working example [here](http://tallymobile.com/test7.html).
the url does not return a json like you would like try without the `callback=function`
with the callback it uses a method called jsonp:
<http://ajaxian.com/archives/jsonp-json-with-padding>