Created
March 26, 2013 12:53
-
-
Save Canx/5245142 to your computer and use it in GitHub Desktop.
basic xhr example
This file contains hidden or 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 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