JSFiddle - React, Tailwind, and code Playground
HTML
<h1>Hello</h1>
<p>A paragraph.</p>
<button id="buttonthing">Click me and I'll show a HTML source code below!</button>
<div id="thediv"></div>
JavaScript
$("#buttonthing").click(function () {
$.ajax({
//Here you'd put the URL to the file, e.g. http://yourdomain.com/file.txt
//I can't access external URLs in jsFiddle AJAX
url: '/echo/html',
success: function(data){
//We would use the below to diplay the data from the fetched file
//$("#thediv").text(data);
//But as we are fetching a blank document, let's use some hard-coded instead.
$("#thediv").text('<html><head><title>Hello!</title></head></html>')
},
error: function(error){
alert('Uh oh, some error occurred.');
}
});
});