JSFiddle - React, Tailwind, and code Playground
by petersendidit
HTML
<h1>This is all that is in the html</h1>
<button id="trigger_ajax">Push me</button>
<div id="main-content"></div>
JavaScript
$("#trigger_ajax").bind("click", function() {
var html ="<h2>Hello World - This is request 1<span></span></h2>";
html += "<scr"+"ipt>";
html += "$('h2').bind('mouseover',function () { var h2 = $(this); setTimeout(function(){ h2.find('span').text('hello'); console.log(h2); }, 1000); h2.remove(); });";
html += "</scr"+"ipt>";
$.ajax({
url: "/echo/html/",
type: "POST",
data: {
"html": html,
"delay": 3
},
success: function(returned_data) {
$("#main-content").html(returned_data);
}
});
$.ajax({
url: "/echo/html/",
type: "POST",
data: {
"html": "<h2>Hello World - This is request 2</h2>"
},
success: function(returned_data) {
$("#main-content").html(returned_data);
}
});
});