If you use any of my webapps that return json data, there will be an option to return jsonp instead. Here's a quick summary of what it's all about.
All this is relevant for GAS because it will typically be running on the google.com domain, whereas you will calling from some other domain of your own. At this time, you cannot setup CORS for Google Apps Script , so for now we have to continue to use JSONP. You can take a look at this blog post for more about what works and what doesn't work on GAS. Note that the same-origin loophole I refer to in this post has since been plugged.
so this JSON
becomes this JSONP
The Mime Type describes what should be done with a set of data. That means that if you are returning JSON data you need to set a different Mime Type than the one needed for JSONP. In Google Apps Script terms, these are
My webapps all provide a standard way to ask for JSONP rather than JSON. If you specify &callback=somefunction on the webapp url, then you'll get JSONP, otherwise you'll get JSON. Note that only GET provides JSONP. If you want to do POST or some other operation, then you need to make the requests from a server - or via a server proxy. But that's a post for another day.
Here's a typical doGet() function, supporting both JSONP and JSON
For more like this see Google Apps Scripts snippets
You want to learn Google Apps Script?
Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas - from VBA to Apps script, available All formats are available now from O'Reilly,Amazon and all good bookshops. You can also read a preview on O'Reilly.
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Google Apps Scripts snippets >