Project

General

Profile

Actions

Support #8158

open

WT application initialization in HTML file

Added by Alex Fedorov about 3 years ago. Updated about 3 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
03/01/2021
Due date:
% Done:

0%

Estimated time:

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

hello.html (2.13 KB) hello.html Alex Fedorov, 03/01/2021 05:26 AM
Actions #1

Updated by Alex Fedorov about 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&amp;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.

Actions

Also available in: Atom PDF