Difference between revisions of "Code for APP"
Jump to navigation
Jump to search
Line 44: | Line 44: | ||
</pre> | </pre> | ||
[[Ajax]] | ==[[Ajax | Back to Previous Page]]== |
Latest revision as of 14:11, 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(); } })();