Difference between revisions of "Code for APP"
Jump to navigation
Jump to search
(Created page with "'''Text file is created with text''' <h2> Outwter Plastics </h2> '''HTML code''' <pre> <body> <button id="btn" type="">Click Me</button> <div id="output"> </div>...") |
(No difference)
|
Revision as of 14:08, 16 November 2016
Text file is created with text
Outwter Plastics
HTML code
<body>
<button id="btn" type="">Click Me</button>
<div id="output">
</div>
<script src="script.js"> </script>
</body>
Java Script Code
(function() {
document.querySelector('#btn').addEventListener('click', showData);
function showData() {
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
console.log(httpRequest.responseText);
document.querySelector('#output').innerHTML = httpRequest.responseText;
} else {
console.log('Not ready yet:');
}
};
httpRequest.open('GET', 'test.txt', true);
httpRequest.send();
}
})();