Created
March 22, 2012 19:39
-
-
Save thinkphp/2162717 to your computer and use it in GitHub Desktop.
YQLQuery minified
This file contains hidden or 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
function YQLQuery(query,callback,format,diagnostics){this.query=query;this.format=format||"json";this.diagnostics=diagnostics||false;this.callback=callback||function(){};}YQLQuery.prototype.fetch=function(){if(!this.query||!this.callback){console.log("Fetch error: missing parameters!");return;}var scriptEl=document.createElement("script"),endpoint="http://query.yahooapis.com/v1/public/yql?q=",env="&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys",encodedURL=encodeURIComponent(this.query),format=this.format,id="yql"+(+new Date()),that=this,src=endpoint+encodedURL+"&format="+format+"&callback=YQLQuery."+id+"&diagnostics="+this.diagnostics+env;YQLQuery[id]=function(data){if(window.console){console.log(data);}that.callback(data);delete YQLQuery[id];document.body.removeChild(scriptEl);};scriptEl.src=src;document.body.appendChild(scriptEl);}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment