jquery - Rest Query correct but YQL doesn't pull data -
i have found sample code modifications not getting results. sample code works , found @ puppy tweets
this way i've modified , no results:
<script> function handleresponse (json) { var results = json.query.results.json.results, ul = document.getelementsbytagname( 'ul' )[0], li = null; ( var = 0; < results.length; i++ ) { li = document.createelement( 'li' ); li.innerhtml = results[i].text; ul.appendchild( li ); } } </script> <script src="select * html url="http://www.fishingnotes.com/lakeinfo.php?id=38742" , xpath='//div[@class="lbox"]/div[1]/div/span[1]'"></script>
i've used yql console verify rest query correct. need do?
your main mistake trying use (only) yql query source of javascript script. needs url, can provided yql console highlighted below.
so <script>
element might like:
<script src="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3d%22http%3a%2f%2fwww.fishingnotes.com%2flakeinfo.php%3fid%3d38742%22%20and%20xpath%3d'%2f%2fdiv%5b%40class%3d%22lbox%22%5d%2fdiv%5b1%5d%2fdiv%2fspan%5b1%5d'&callback=handleresponse"></script>
there couple of minor issues javascript itself. basic working version might like:
<script> function handleresponse (json) { var ul = document.getelementsbytagname( 'ul' )[0], li = null; ( var = 0; < json.query.count; i++ ) { li = document.createelement( 'li' ); li.innerhtml = json.results[i]; ul.appendchild( li ); } } </script>
see » example on js bin.
Comments
Post a Comment