Highlighted

json from an iframe to coldfusion structure or parm

New Here ,
Sep 09, 2015

Copy link to clipboard

Copied

I am trying to figure out how to get json data that is coming from an iframe response into a coldfusion parameter or structure that I can use.  The iframe is within a form and when submitted it executes the doMonerisSubmit function in the javascript.  Below is the javascript which returns the information but I need to get it into CF.  If it was using a cfhttp post I could do it, but I'm at a loss as to how to capture it when it's being executed in this javascript.  I've been working on this off and on for the past month and I'm no closer to a solution now than I was a month ago.  Any insight would be appreciated.

Thanks.

<script>
function doMonerisSubmit()
{
var monFrameRef = document.getElementById('monerisFrame').contentWindow;
monFrameRef.postMessage('','https://esqa.moneris.com/HPPtoken/index.php');
return false;
}
var respMsg = function(e)
{
var respData = eval("(" + e.data + ")");

document.getElementById("monerisResponse").innerHTML = e.origin + " SENT " + " - " +
respData.responseCode + "-" + respData.dataKey + "-" + respData.errorMessage;
document.getElementById("monerisFrame").style.display = 'none';
}
window.onload = function()
{
if (window.addEventListener)
{
window.addEventListener ("message", respMsg, false);
}
else
{
if (window.attachEvent)
{
window.attachEvent("onmessage", respMsg);
}
}
}
</script>

TOPICS
Advanced techniques

Views

516

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

json from an iframe to coldfusion structure or parm

New Here ,
Sep 09, 2015

Copy link to clipboard

Copied

I am trying to figure out how to get json data that is coming from an iframe response into a coldfusion parameter or structure that I can use.  The iframe is within a form and when submitted it executes the doMonerisSubmit function in the javascript.  Below is the javascript which returns the information but I need to get it into CF.  If it was using a cfhttp post I could do it, but I'm at a loss as to how to capture it when it's being executed in this javascript.  I've been working on this off and on for the past month and I'm no closer to a solution now than I was a month ago.  Any insight would be appreciated.

Thanks.

<script>
function doMonerisSubmit()
{
var monFrameRef = document.getElementById('monerisFrame').contentWindow;
monFrameRef.postMessage('','https://esqa.moneris.com/HPPtoken/index.php');
return false;
}
var respMsg = function(e)
{
var respData = eval("(" + e.data + ")");

document.getElementById("monerisResponse").innerHTML = e.origin + " SENT " + " - " +
respData.responseCode + "-" + respData.dataKey + "-" + respData.errorMessage;
document.getElementById("monerisFrame").style.display = 'none';
}
window.onload = function()
{
if (window.addEventListener)
{
window.addEventListener ("message", respMsg, false);
}
else
{
if (window.attachEvent)
{
window.attachEvent("onmessage", respMsg);
}
}
}
</script>

TOPICS
Advanced techniques

Views

517

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 09, 2015 0
BKBK LATEST
Adobe Community Professional ,
Sep 15, 2015

Copy link to clipboard

Copied

So far, you are receiving the information in the browser. You could, for example, add AJAX code that would send that information to the Coldfusion server, that is, to a CFM page, via a GET or POST method. Google will tell you more.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 15, 2015 0