0

$.getJSON is not reurning from particular host/site

Hi,

Below is the code snippet I am using for fetching the html content.

<

script> // JavaScript Document$(document).ready(function(){

 // Accepts a url and a callback function to run. 
function requestCrossDomain( site, callback ) { 

    // If no url was passed, exit. 
    if ( !site ) { 
        alert('No site was passed.'); 
        return false; 
    } 

    // Take the provided url, and add it to a YQL query. Make sure you encode it! 
    var yql = '<http://query.yahooapis.com/v1/public/yql?q=>' + encodeURIComponent('select * from html where url="' + site + '"') + '&format=xml&callback=?'; 
    alert(yql);
    // Request that YSQL string, and run a callback function. 
    // Pass a defined function to prevent cache-busting. 
    $.getJSON( yql, cbFunc ) 
    .done(function() { console.log( "second success" ); })
    .fail(function(jqxhr, textStatus, error) { console.log( "error", textStatus, error ); })
    .always(function() { console.log( "complete" ); });

    function cbFunc(data) {

    if ( data.results[0] ) { 
        // Strip out all script tags, for security reasons. 
        // BE VERY CAREFUL. This helps, but we should do more.  
        data = data.results[0].replace(/<script[^>]*>[\s\S]*?<\/script>/gi, ''); 

        // If the user passed a callback, and it 
        // is a function, call it, and send through the data var. 
        if ( typeof callback === 'function') { 
            callback(data); 
        }
        alert('Somethiong got');
    } 
    // Else, Maybe we requested a site that doesn't exist, and nothing returned. 
    else
    {
        alert('nothing returned');
        //throw new Error('Nothing returned from getJSON.'); 
    }
    }

} 
    requestCrossDomain('<http://www3.colonialfirststate.com.au>', function(results) { 
    //alert(results);
   $('#results').html(results); 
}); 

Only for the website "http://www3.colonialfirststate.com.au" it is not returning anything. But other sites like google.com,microsoft.com ... etc works perfectly.

Do we need to do any settings/proxy enable on the server "<www3.colonialfirststate.com.au>". It is amazone cloud server.

For the past week I am trying different option to solve this issue. Can anyone help me on this.

Regards

Meera

by
0 Replies

Recent Posts

in YQL