O'Reilly logo

Mastering jQuery UI by Vijay Joshi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Displaying posts from the reddit front page

We already created an example using the reddit API in Chapter 4, Creating a Tabbed News Reader. If you have gone through it, you can directly skip the theory section and directly use the code and implement it.

Unlike Chapter 4, Creating a Tabbed News Reader, in this widget we will display the posts from the reddit front page. Like earlier widgets, we will call the reddit API for JSON of front page posts. Once data is received, we will iterate in response items and create the DOM. Write the following code inside initReddit method to call the API:

var apiURL = 'http://www.reddit.com/r/all.json'; $.ajax( { url: apiURL, dataType: "jsonp", jsonp: 'jsonp', success: function(data) { var x = {a : data}; console.log(x); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required