Pregunta

I found a trickshot

// Define variables
var query = 'select * from data.html.cssselect where url="http://www.chucknorrisfacts.com/chuck-norris-top-50-facts" and css=".field-content a"';
var yqlAPI = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) + ' &format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=?';
$.getJSON(yqlAPI, function(r){
    console.log('Chuck Norris Facts:');
$.each(r.query.results.results.a, function(){ console.log('----------'); console.log(this.content);
}); }); 

Sound great but it doesn't work.

Found this : http://tutorialzine.com/2010/02/feed-widget-jquery-css-yql/ same problem. https://github.com/hail2u/jquery.query-yql download, unzip, run on a server and nothing.

YQL console with the first query is slow but works.

How can I use YQL with js ? Does OAuth necessary ?

update : screenshot with console

¿Fue útil?

Solución

Apologies, I found the answer… this is not YAHOO but my local network and his gateway (modem).

I make a succesfull test using a Tethering conection. So I go to my gateway admin page.


Firewall

Web Content Filter : This page allows certain Web-oriented cookies, java scripts, and pop-up windows to be blocked by the firewall. A list of "trusted computers" can also be defined that are not subject to any filters configured. Specific Firewall features can also be enabled. It is highly recommended that the Firewall is left enabled at all times for protection against Denial of Service attacks. Go to the Parental Control page to block internet access to specific sites.

Web Features

  • Filter Proxy uncheck
  • Filter Cookies uncheck
  • Filter Java Applets uncheck
  • Filter ActiveX uncheck
  • Filter Popup Windows uncheck
  • Block Fragmented IP Packets uncheck
  • Port Scan Detection uncheck
  • IP Flood Detection uncheck
  • Firewall Protection > was checked

Unchecked the last item and now it's work ! I never had any problems with this firewall, using ajax, nas config, dlna protocol, running a mysql on local server…

To be more specific, this is a Thomson twg850-4 (rented by my ISP).

Otros consejos

Don't quite know what your problem was, but your initial script works as is.

I've made a few changes to add it into a page and create the content inline, tested and running under the following browsers:

Chrome 31.0.1650.63 m Firefox 26.0 IE 11.0 IE 10.0 IE 9.0

<!DOCTYPE html />
<html>

  <head>
    <title>Chuck Norris facts</title>
  </head>

  <body>
    <h1>Chuck Norris facts</h1>

    <ul id="facts">
    </ul>

    <script src="http://code.jquery.com/jquery-2.0.3.min.js" type="text/javascript"></script>
    <script type="text/javascript">

      $(document).ready(function ()
      {
        getFacts();
      });

      var query = 'select * from data.html.cssselect where url="http://www.chucknorrisfacts.com/chuck-norris-top-50-facts" and css=".field-content a"';
      var yqlAPI = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) + ' &format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=?';

      function getFacts()
      {
        $.getJSON(yqlAPI, function (r)
        {
          console.log('Chuck Norris Facts:');
          $.each(r.query.results.results.a, function ()
          {
            $('#facts').append('<li>' + this.content + '</li>');
          });
        });
      }

    </script>
  </body>

</html>

Things I would check:

your browser version and jQuery version. In my code above i've used the latest jQuery from the CDN endpoint, and i tested it in a lot of browsers.

I've got it working in the modern versions, but IE8 and less didn't work at all.

This is not a surprise though, as any jQuery after 1.9 wont work in less than IE9.

I suspect you'll also get similar issues if your Chrome/Firefox/Opera/Maxthon etc has not been updated for sometime.

Beyond that, I can't offer any more advice, as others have said, let people know what the developer tools console in your browser is showing, and even more so let us know your actual browser version.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top