function createSubmissionBox(collection, origin){ var client = new XMLHttpRequest(); client.open('GET', 'https://visitor-gallery.clevelandart.org/api/submit/get-widget/input.html'); client.onload = function() { submissionBox = client.responseText; submissionBox = submissionBox.replace("PLACE-HOLDER-COLLECTION", collection); submissionBox = submissionBox.replace("PLACE-HOLDER-ORIGIN", origin); var submissionNode = document.createRange().createContextualFragment(submissionBox); //This is where the widget is added var placeHolder = document.getElementById('submission-box-container'); placeHolder.appendChild(submissionNode); } client.send(); }