6 ms·
About JSONP in JavaScript
- ronnier 16y agoI recently added JSONP support to http://api.ihackernews.com http://api.ihackernews.com (Hacker News API). Works great for making widgets only using front-end code.
- bluedevil2k 16y agoReading through this makes me appreciate the automatic steps that jQuery uses when getting a site's JSONP. Things like automatic method name creation.
- PanMan 16y agoYes, but it's annoying you can't set the callback name to something static (for when the JSONP provider doesn't support variable callbacks). You can, but need a Jquery JSONP plugin for that.
- deleted 16y ago[deleted]
- deleted 16y ago[deleted]
- catshirt 16y agoI agree jQuery helps immensely because it is annoying, but it's not exactly a chore. I've never actually implemented JSONP outside of jQuery, but I'd imagine we're talking about maybe 3 lines (a few more to check for dupe functions).
- DanHulton 16y agoAs an FYI, don't forget to add a timestamp to your JSONP request URLs, otherwise the user's browser may cache the results. Had that problem once. Once. (But for way too long.)
- drgath 16y agoFYI: YQL supports JSONP callbacks, so check it out if you come across something that doesn't support JSONP, or doesn't even have an API. http://developer.yahoo.com/yql/ http://developer.yahoo.com/yql/
- moron4hire 16y agoIf I need to get around a XSS limitation, I prefer JSON proxies on the server. I have a server-side handler forward its parameters to the remote request and echo the remote resource's response (with validation) as the proxy's response.