Code for APP
Jump to navigation
Jump to search
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(); } })();