Skip to content

Instantly share code, notes, and snippets.

@Canx
Created March 26, 2013 12:53
Show Gist options
  • Save Canx/5245142 to your computer and use it in GitHub Desktop.
Save Canx/5245142 to your computer and use it in GitHub Desktop.
basic xhr example
function init() {
// Cargar el objeto Json remotamente
var xhr = createXHR();
xhr.onreadystatechange = function(){
if (xhr.readyState == 4){
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304){
alert(xhr.responseText);
} else {
alert(“Request was unsuccessful: “ + xhr.status);
}
}
};
xhr.open("get", "libros.txt", false);
xhr.send(null);
//var entries = JSON.parse(jsonEntries);
}
window.init = init;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment