JSFiddle - React, Tailwind, and code Playground
JavaScript
// Code that loads stuff from the server..
function loadJson() {
$.getJSON('/some/url/', contentLoaded);
}
/*
The response JSON is:
{ result: true,
data: { id: '1' },
content: '
<script type="text/javascript">
$(document).ready(function() {
var elementIWannaGet = $('html-content-div'); // lenght = 0 for some reason..
}
</script>
<div id="html-content-div">Html content! :D</div>'
}
*/
function contentLoaded(response) {
if (response.result == true)
handleError(response);
// Get the container where the response.content will be rendered to.
var targetContainer = $('#target-container-id');
// Append the content
targetContainer.append(response.content);
}