mercredi 4 février 2015

YQL not calling callback function when querying Google Drive


This is my first time using YQL for a project, so apologies if I'm making a stupid error.


I'm trying to use YQL to get a list of the contents of a publicly viewable Google Drive folder, which I can then manipulate via Javascript. I'm basing my JavaScript very closely on the example code from Yahoo, but my code isn't working. (I have gotten the actual example to work.) It seems like YQL isn't even triggering the callback function, but I'm not even sure if how to debug what's going on.


Here's my query on the YQL console, where it seems to be working.


And here's the HTML of my test page, where nothing is happening:



<!DOCTYPE html>
<html>
<head>
<title>
Test
</title>
<script type="text/javascript">
//Parses returned response
function specialhelper (yqlQuery) {
//Attenpt to see if function is even being called
document.getElementById("yes").innerHTML = "Yes!"

var items = yqlQuery.query.results.a;
var output = "";
var no_items=items.length;
for(var i=0;i<no_items;i++){
var iHref = contents[i].href;
var iContent = contents[i].content;
output += "<p><b>" + iContent + "</b> " + iHref + "</p>"
}
// Place output in div tag
document.getElementById('results').innerHTML = output;
}
</script>
</head>

<body>

<p id="yes">No</p>

<!-- Div tag for results -->
<div id='results'></div>

<!-- The YQL statment will be assigned to src. -->
<script src="http://ift.tt/1KsxpHW'%2F%2Fdiv%5B%40class%3D%22folder-cell%22%5D%2Fa'&format=json&callback=specialhelper">

</body>




Aucun commentaire:

Enregistrer un commentaire