VL Group

Rhymba v3.6 Documentation

Intro to JSONP

JSONP is a mechanism you can use to get around the same-origin policy in browsers' Javascript security. What it does, in a very small and basic nutshell, is place your request into a special <script> tag since script tags can get around the same-origin security policy. By telling Rhymba that you want a $callback, the function you name in this callback parameter will be called upon successful request, with the JSON returned being passed as a parameter.

You can read more about JSONP on the http://json-p.org site. If you're using jQuery, the built-in jQuery.ajax method can handle the heavy lifting of JSONP for you... but we've found that we prefer to replace it with the excellent jQuery-JSONP plugin, which adds error callbacks (jQuery core's AJAX handling won't hit error callbacks when using JSONP) among other useful features. In a future documentation update, there will be working examples using jQuery-JSONP in a "Samples" section, and jQuery-JSONP is what powers our Exampler.js widget on this documentation site.