Google Caching and faking jsonp

In using Google Apps Script as a jSONP proxy, I covered how you could use GAS to get over javaScript same domain restrictrictions. If you need to access jSon data from javaScript, jQuery and so on, and your script is running locally or the data in a different domain than your script, unless the data hosting platform supports jsonp, you are going to find it difficult to acces that data from javaScript.

You can access this as in this jQuery example.

where

  • url is the address of your (non-jsonp capable) data .. for example
  • proxyJsonp is the shared url of your Google Apps script jsonp faker. There’s one at https://script.google.com/a/macros/mcpher.com/s/AKfycbzGgpLEWS0rKSBqXG5PcvJ7Fpe02fvGqiCqq54SVQmBJSpy_6s/exec

Caching with Google Apps Script
Another benefit of ‘faking’ jSonP by using Google Apps Script is that you can use the Google Caching service. This means that multiple urlFetches() to slower hosting platforms can be avoided, since the GAS jsonP faker will cache data with the same URL. For details of how this works, see using Google Cache.

About brucemcp 223 Articles
I am a Google Developer Expert and decided to investigate Google Apps Script in my spare time. The more I investigated the more content I created so this site is extremely rich. Now, in 2019, a lot of things have disappeared or don’t work anymore due to Google having retired some stuff. I am however leaving things as is and where I came across some deprecated stuff, I have indicated it. I decided to write a book about it and to also create videos to teach developers who want to learn Google Apps Script. If you find the material contained in this site useful, you can support me by buying my books and or videos.

Be the first to comment

Leave a Reply

Your email address will not be published.


*


9 − 1 =