Created
January 27, 2014 20:29
-
-
Save victorcastelan/8656641 to your computer and use it in GitHub Desktop.
getJSONP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! jquery.getJSONP */ | |
var jsonp={_config:{id:"fileName"},_callback:{},_params:{},init:function(a){jsonp.parse(a)},parse:function(a){if(!a.hasOwnProperty("meta")||!a.meta.hasOwnProperty(this._config.id)||!jsonp._callback.hasOwnProperty(a.meta[this._config.id]))return"error: jsonp malformed. Wrong meta";var b=jsonp._callback[a.meta.fileName];var p=jsonp._params[a.meta.fileName];delete jsonp._callback[a.meta.fileName];delete jsonp._params[a.meta.fileName];return b(a,p)}}; | |
(function(a){a.getJSONP=function(b,c,d,p){return a.fn.getJSONP(b,c,d,p)};a.fn.getJSONP=function(b,c,d,p){b=b||!1;c=c||!1;d=d||!1;p=p||!1;"function"==a.type(c)&&(p=d,d=c,c={});if(!b||!d)return"getJSONP error: not url or callback";var e=b.split("/").reverse()[0];jsonp._callback[e]=d;jsonp._params[e]=p;a.getJSON(b+"?callback=?&_="+$.now(),c)}})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment