onmessage = function(event) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if (xhr.readyState !== 4) { return; } parent.postMessage(xhr.responseText, "*"); }; xhr.open('POST', location.href, true); xhr.setRequestHeader('Content-Type', 'application/json'); var json; try { json = JSON.stringify(event.data); } catch(e) {} xhr.send(json); };