Created
October 29, 2009 14:52
-
-
Save ftherese/221485 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createRequest() { | |
var result = null; | |
if (window.XMLHttpRequest) { | |
result = new XMLHttpRequest(); | |
if (typeof xmlhttp.overrideMimeType != 'undefined') { | |
result.overrideMimeType('text/xml'); // Or anything else | |
} | |
} | |
else if (window.ActiveXObject) { | |
// MSIE | |
try { result = new ActiveXObject("Microsoft.XMLHTTP");} | |
catch(err){ try{result = new ActiveXObject("MSXML2.XMLHTTP");} | |
catch(err){} | |
} | |
else { | |
// No known mechanism -- consider aborting the application | |
} | |
return result; | |
} | |
for ( i =1; i<=entry.openSearch$totalResults.$t;i+=10) { | |
var req = createRequest(); // defined above | |
// Create the callback: | |
req.onreadystatechange = function() { | |
if (req.readyState != 4) return; // Not there yet | |
if (req.status != 200) { | |
// Handle request failure here... | |
return; | |
} | |
// Request successful, read the response | |
var resp = req.responseText; | |
// ... and use it as needed by your app. | |
} | |
var link = document.createElement('a'); | |
link.href = '#'; | |
link.onclick = function(){req.open("GET", 'http://books.google.com/books/feeds/volumes?q=' + encodeURIComponent(query) + '&min-viewability=partial' + '&start-index=' + i + '&alt=json-in-script&callback=handleResults', true); return false}; | |
textElem.innerHTML = i + ' '; | |
link.appendChild(textElem); | |
document.getElementById("bookBar").appendChild(link); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment