How to use YQL in JavaScript to retrieve web results

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

Answers


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

Need Your Help

<a> tag in html

javascript html jsp

I have the following code in a JSP file:

Developing a Java app that runs both on the web and as an Android app?

java android

I'm working on a game which would work both on the web, as an applet, and on the Android phone, as an app.