Thursday, February 20, 2014

Added JSONP Support for Client Side Calls

Initially, this service was made for server side usage. I received an email request to support client side API calls. The problem is by default browsers do not allow ajax calls from a different domain. They call it the "Same Origin Policy" or SOP. This is a security feature which blocks script calls from different domains because it's potentially unsafe.

I learned that there is a workaround to this issue. You can actually support client side API calls through the use of JSONP or "JSON with padding". This allows client side javascript programs to get data from server with a different domain.

In this service, specifying a "callback" parameter automatically transforms the result to jsonp.