JSFiddle - React, Tailwind, and code Playground
HTML
<div id="response"></div>
JavaScript
var ajax_response='var message="Hello World!";';
function printMessage(){
alert(message);
}
var res=document.getElementById('response');
res.innerHTML="<input type=\"button\" onclick=\"printMessage()\" value=\"test\" />";
var sc=document.createElement('script');
sc.text=ajax_response;
res.appendChild(sc);