Question on create simple call |
Question on create simple call |
soupi |
Aug 12 2020, 10:45 AM
Post
#1
|
Newbie Group: Members Posts: 14 Joined: 14-November 13 Member No.: 19,980 |
Whats the best way to put together a simple webpage that contains a javascript code that calls an ajax function to retrieve some data and finally display that data in the simple webpage.
currently I only have CODE <!DOCTYPE html> <html> <body> <div id="demo"> <h2>AJAX Text</h2> <button type="button" onclick="loadDoc()">Change Content</button> </div> <script> function loadDoc() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("demo").innerHTML = this.responseText; } }; xhttp.open("GET", "ajax_info.txt", true); xhttp.send(); } </script> </body> </html> |
Lo-Fi Version | Time is now: 24th April 2024 - 06:55 PM |