Why does my jQuery/YQL call not return anything?

Posted by tastyapple on Stack Overflow See other posts from Stack Overflow or by tastyapple
Published on 2010-12-25T21:39:16Z Indexed on 2010/12/25 21:54 UTC
Read the original article Hit count: 223

Filed under:
|

I'm trying to access YQL with jQuery but am not getting a response:

http://jsfiddle.net/tastyapple/grMb3/

Anyone know why?

$(function(){
     $.extend(
         {
             _prepareYQLQuery: function (query, params) {
                 $.each(
                     params, function (key) {
                         var name = "#{" + key + "}";
                         var value = $.trim(this);
                         if (!value.match(/^[0-9]+$/)) {
                             value = '"' + value + '"';
                         }
                         query = query.replace(name, value);
                     }
                 );
                 return query;
             },
             yql: function (query) {
                 var $self = this;
                 var successCallback = null;
                 var errorCallback = null;

                 if (typeof arguments[1] == 'object') {
                     query = $self._prepareYQLQuery(query, arguments[1]);
                     successCallback = arguments[2];
                     errorCallback = arguments[3];
                 } else if (typeof arguments[1] == 'function') {
                     successCallback = arguments[1];
                     errorCallback = arguments[2];
                 }

                 var doAsynchronously = successCallback != null;
                 var yqlJson = {
                     url: "http://query.yahooapis.com/v1/public/yql",
                     dataType: "jsonp",
                     success: successCallback,
                     async: doAsynchronously,
                     data: {
                         q: query,
                         format: "json",
                         env: 'store://datatables.org/alltableswithkeys',
                         callback: "?"
                     }
                 }

                 if (errorCallback) {
                     yqlJson.error = errorCallback;
                 }

                 $.ajax(yqlJson);
                 return $self.toReturn;
             }
         }
     );

  $.yql(
    "SELECT * FROM github.repo WHERE id='#{username}' AND repo='#{repository}'",
    {
      username: "jquery",
      repository: "jquery"
    },
    function (data) {
        if (data.results.repository["open-issues"].content > 0) {
            alert("Hey dude, you should check out your new issues!");
        }
    }
  );
 });

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about yql