I'm not even sure if this is possible or not, but I am trying to display an HTML page, formatted as JSON, and then call a function whenever the user clicks on a button inside of this returned HTML. I know this is weird, but this is the way the customer wants it. Can anyone tell me if this is even possible? And also, I already have the page displaying correctly. The only issue is actually executing a function when the user clicks a button on this page.
{
"responseHTML": "<script>console.log('TEST')</script><div><button onclick='test()'></button></div>"
}
display an HTML page, formatted as JSONscriptcontents won't execute that way. A newscriptelement must be created via the DOM and a text node created for it.