Skip to content

Instantly share code, notes, and snippets.

@codeniko
Last active August 29, 2015 14:27
Show Gist options
  • Save codeniko/8ab3030d2f4b7c1ae7b3 to your computer and use it in GitHub Desktop.
Save codeniko/8ab3030d2f4b7c1ae7b3 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script>
function getContent() {
http.get('content.php', function (res) {
var resChunks = '';
res.on('data', function (data) {
resChunks += data;
})
res.on('end', function () {
var resBody = resChunks || '<h3>No response, this is default</h3>';
document.getElementById("contentbox").innerHTML=resBody;
});
res.on('error', function (e) {
document.getElementById("contentbox").innerHTML='ERROR';
});
});
}
</script>
</head>
<body>
<div id="contentbox"></div>
<button onclick="getContent()">Get Content</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment