Implementing JSONP

We are using the same URL as before to fetch the data, but we have added the jsonp parameter and are setting it to getRedditData; it is important to note that the feed is now padded into our callback getRedditData. Now let's replace the URL property in our earlier script to create a new script that will fetch us the JSON feed.

Implementing JSONP

A few properties such as url and dataType have been modified and a few new properties such as contentType and jsonpCallback have been added. We have already discussed the change in the url property, so let us look at the other properties.

Earlier, the dataType property was set to json as the incoming feed ...

Get JavaScript and JSON Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.