0

I have been trying the code given in How to use YQL to retrieve web results?

but it is not working.

Please suggest me something else or rectify that code.

I am just calling a function on page_load

<body onload = "load_content();">

In the load_content() method, I have to get the feed of other web site and display it on my HTML page.

Load_Content method

     var query = "select * from html where url='http://www.imdb.com/title/tt0123865/'";

    // Define your callback:
    var callback = function(data) {
    console.log("DATA : " + data);
    };

    // Instantiate with the query:
    var firstFeedItem = new YQLQuery(query, callback);

    // If you're ready then go:
    console.log("FEED : " + firstFeedItem.fetch()); // Go!!

Function YQLQuery

    function YQLQuery(query, callback) 
    {
        this.query = query;
        this.callback = callback || function(){};
        this.fetch = function() {

        if (!this.query || !this.callback) {
            throw new Error('YQLQuery.fetch(): Parameters may be undefined');
        }

        var scriptEl = document.createElement('script'),
            uid = 'yql' + +new Date(),
            encodedQuery = encodeURIComponent(this.query.toLowerCase()),
            instance = this;

        YQLQuery[uid] = function(json) {
            instance.callback(json);
            delete YQLQuery[uid];
            document.body.removeChild(scriptEl);
        };

        scriptEl.src = 'http://query.yahooapis.com/v1/public/yql?q='
                     + encodedQuery + '&format=json&callback=YQLQuery.' + uid; 
        document.body.appendChild(scriptEl);

    };
  }

Nothing is coming in data variable

Community
  • 1
  • 1
Saurabh Saxena
  • 3,005
  • 10
  • 31
  • 46

1 Answers1

0

A simple get request is an answer to this.

 $.get("http://www.imdb.com/title/tt1243957/",
    function(data){
        console.log(data);
    }//end function(data)
 );//end getJSON
Saurabh Saxena
  • 3,005
  • 10
  • 31
  • 46