JSFiddle - React, Tailwind, and code Playground

by tonyleeper

HTML

<iframe id="target"></iframe>

CSS

body {
    background-color: #ffffff;
}

iframe {
    width: 400px;
    height: 400px;
    border: 1px solid #00aa00;
}

JavaScript

/**
 * Creative Builder preview SPIKE
 */

var target = document.getElementById('target');
var url = 'http://uat.dynamicmessenger.com/EM.svc/GetTemplateContent';
var requestBody = {"Token":"570c6e4c-1b55-4aa9-87b8-e516cf4ca817","CreativeID":24918,"ContentType":0};

var xmlhttp = new XMLHttpRequest(),
    method = 'POST';

xmlhttp.open(method, url, true);
xmlhttp.onreadystatechange = function () {
    if (xmlhttp.readyState !== XMLHttpRequest.DONE) {
        return;
    }
    
    if (xmlhttp.status === 200) {
        var response = JSON.parse(xmlhttp.responseText);
    	target.contentWindow.document.write(response.GetTemplateContentResult);
    }
};
xmlhttp.setRequestHeader("Content-type", "application/json");
xmlhttp.send(JSON.stringify(requestBody));