Skip to content

Instantly share code, notes, and snippets.

@armaandh
Created January 30, 2018 05:13
Show Gist options
  • Select an option

  • Save armaandh/c1815ba6231923aaab88b6abfef69bf1 to your computer and use it in GitHub Desktop.

Select an option

Save armaandh/c1815ba6231923aaab88b6abfef69bf1 to your computer and use it in GitHub Desktop.
my proj code
<html><head>
<style>
#myDiv {
max-width: 850px;
margin: auto;
}
</style>
<script>
onload = function(){
var i = 0;
var timer = setInterval(function(){
var req = new XMLHttpRequest();
req.open("GET", i+1+".txt", true);
req.onreadystatechange = function() {
if(req.readyState == 4){
if(req.status == 200) {
if(i == 1) {
var para = document.createElement("P");
para.id = "pTag";
var t = document.createTextNode("");
para.appendChild(t);
para.innerText = req.responseText;
document.getElementById("myDIV").appendChild(para);
} else {
document.getElementById("pTag").innerText += req.responseText;
}
}
}
}
req.send(null);
i++;
if(i > 10) {
clearInterval(timer);
}
}, 5000);
}
</script></head><body>
<div id="myDIV"></div>
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment