Skip to content

Instantly share code, notes, and snippets.

@d30jeff
Created July 25, 2015 08:49
Show Gist options
  • Select an option

  • Save d30jeff/654d84d69c3b047a6a7f to your computer and use it in GitHub Desktop.

Select an option

Save d30jeff/654d84d69c3b047a6a7f to your computer and use it in GitHub Desktop.
Dojo
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript" src="dojoroot/dojo/dojo.js"
djConfig="parseOnLoad: true, isDebug: false">
</script>
<script type="text/javascript">
function readFile() { //
dojo.xhrGet({ //
// The following URL must match that used to test the server.
url: "http://www.vogella.com/tutorials/AjaxwithDojo/download/includeTextFile.txt",
handleAs: "text",
timeout: 5000, // Time in milliseconds
// The LOAD function will be called on a successful response.
load: function(response, ioArgs) { //
dojo.byId("replace").innerHTML = response; //
return response; //
},
// The ERROR function will be called in an error case.
error: function(response, ioArgs) { //
console.error("HTTP status code: ", ioArgs.xhr.status); //
dojo.byId("replace").innerHTML = 'Loading the ressource from the server did not work'; //
return response; //
}
});
}
</script>
<script type="text/javascript">
dojo.addOnLoad(readFile);
</script>
</head>
<body>
<div id="replace" style="font-size: big"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment