0

I'm trying to get the JSON file of a certain page on reddit and it cancels with no reason why..

Here's the URL i am trying to parse with JSON. http://reddit.com/r/VillagePorn/.json

UPDATED CODE:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <title>Sin título 1</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>    
    <script type="text/javascript">
$(document).ready(function () {    

                $.ajax({
    type: "GET",
    dataType: "json",
    url: "http://reddit.com/r/VillagePorn/.json?jsonp=?",
    success: function (data) {    
    $.each(data.data.children, function(i,item){
        $("<img/>").attr("src", item.data.url).appendTo("#res");
    });


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

<div id="res"></div>

</body>
</html>
test
  • 17,706
  • 64
  • 171
  • 244

1 Answers1

1

here is a working example : http://jsfiddle.net/fuRkG/

I think the issue is with the url , you need to add jsonp=? at the end

Answer based on this previous question : How to extract url data from Reddit API using JSON

Community
  • 1
  • 1
Tarek
  • 3,810
  • 3
  • 36
  • 62
  • I'm getting `Uncaught SyntaxError: Unexpected token ? ` in Line 22 which is the closing `});` of the last thing. I updated my code. – test Jul 06 '12 at 02:18