I'm building a JSON string within script Tags in a cfm file. I would like to find a way to get this JSON string into a cfoutput so that the page can display the JSON.
I'm currently just document.write()
ing the json which retrieves the JSON in the browser but won't return anything with a POST request. I've tried using the toScript() coldfusion function but I think this does the opposite of what I want (puts cf var into js when I want to put a js var into cf).
I'm currently doing this
<cfoutput>
<script type = "text/javascript">
var someJSON = "{\"some\": \"data\"}";
document.write(JSON.stringify(someJSON));
</script>
</cfoutput>
I'm still getting to grips with coldfusion so sorry if this seems archaic. I would like to instead pass someJSON
to a coldfusion variable so I can cfoutput tag so that I get a response with a POST request to this particular endpoint because currently I get no response.