javascript - Retrieve the url from a yql result -
i have been trying understand how return links yql results, far thing im getting [object object] , not getting anywhere far, care explain me why happening? want display results links.
<div id="funfacts"> </div> <script> function funfacts(o){ var facts = document.getelementbyid('funfacts'); if(facts){ var data = o.query.results.a; var out = document.createelement('a'); out.classname = 'fact'; facts.appendchild(out); out.innerhtml = data.join("<br />"); } } </script> <script src="http://query.yahooapis.com/v1/public/yql?q=select%20href%20from%20html%20where%20url%3d'http%3a%2f%2fcid-a59bebc211b678a6.office.live.com%2fbrowse.aspx%2fpublic%2fhi5'%20and%20xpath%3d'%2f%2fa%5b%40id%3d%22download%22%5d'%0d%0a&format=json&diagnostics=true&callback=funfacts"></script>
i hope example enough understanding, trying display list of urls page, returns list of [object object] lines.
if console.log on return object you'll see results array 3 arrays within it. url need o.query.results.a[n].href
results: object a: array[3] 0: object href: "http://public.blu.livefilestore.com/y1pxkbpqgst2tkgdjlyaooylwspbnyldxvtohor4w0serdcycncgu4lr8bg4e81w…" __proto__: object 1: object 2: object
here jsfiddle
Comments
Post a Comment