I recently found myself a bit confused on how to convert a JQuery $.getJSON() call to use JSONP (JSON with Padding).
JSONP is a way to get around the Same Origin Policy restriction when a script in one domain wants to fetch JSON data from a server in a different domain.
The approach is simple enough but I had trouble finding a clear explanation. So I wrote up a simple example in both JSON and JSONP with server and client code.
The live demo is at http://json-jsonp-tutorial.craic.com and all the code is on Github at https://github.com/craic/json_jsonp_tutorial
I hope that you find it useful...
Archive of Tips
- ▼ 2013 (26)
- ► 2012 (28)
- ► 2011 (44)
- ► 2010 (40)
- ► 2009 (53)
- ► 2008 (21)