Support #8158
openWT application initialization in HTML file
0%
Description
I want to create several embedded WT widgets and initialized them in HTML file. I want to send a text message to the server application so it can initialize one or several placeholders.
What is the best way to do that?
I tried to send XMLHttpRequest to the server but I'm not sure how to handle such request in my application (see HTML file attached). How to specify the application ID in such request? Do you have an example of connecting such request to a server-side function?
$(document).ready(function()
{
alert("The DOM is ready!");
const url='http://127.0.0.1:8080/hello.js';
alert("POST request");
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader("dataset", "test");
xhr.onreadystatechange = function()
{
if (this.readyState === XMLHttpRequest.DONE && this.status === 200)
{
// Request finished. Do processing here.
alert("POST request is finished");
}
}
xhr.send("Init");
})
Files
Updated by Alex Fedorov over 3 years ago
I have found solution here:
https://www.webtoolkit.eu/wt/news/2010/12/17/widgetset_mode_and_cross_origin_requests
https://redmine.emweb.be/boards/2/topics/16917?r=16923#message-16923
<!--
As the last step, we load our application.
-->
<!--<script src="http://127.0.0.1:8080/iglserver.js?div=chart&Wt-history=Wt-history"></script>-->
<script src="http://127.0.0.1:8080/iglserver.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
function InitApplication()
{
alert("InitApplication request.");
dataText = "test data";
main.emit(main, 'onInit_Signal', dataText);
}
/* ]]> */
</script>
Please close the issue.