What I am trying to achieve is that I want my chat-bot application to be a part of the other application when getting called via asynchronous JavaScript calling. Though the chat-bot itself is an independent application.
I am able to get the Html page as a response of JavaScript Ajax calling but the script content is not visible/ getting executed/ shown on browser. I tried so many solutions which are there online including the eval() function but those didn't work. Looking out for help from the Stack Overflow community.
<div id="x"></div>
<script>
function y() {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
console.log(xmlHttp.responseText);
/* Append the fetched content to the 'x' div */
document.getElementById('x').innerHTML = this.responseText;
}
}
xmlHttp.open('GET', 'http://localhost:port_no/application_Page', true);
xmlHttp.setRequestHeader('Content-type', 'text/html');
xmlHttp.send();
}
y();
</script>
What is expected that I want my chat-bot to come like a floating window on top of the parent application with all the HTML, CSS properties so that it works same as how it works as an individual application. Like this I want