Project

General

Profile

just a simple response from Wt server

Added by alex merge over 8 years ago

Hi! I'm messing something, please help to find proper solution.

im calling wt.emit(...) from my custom js widget. Process this call on C side and want to return some JSON feedback to JS code immediately. How to do it?

Thanks a lot for any ideas.


Replies (4)

RE: just a simple response from Wt server - Added by Koen Deforche over 8 years ago

The communication from JavaScript to server happens asynchronously (you cannot make the JavaScript 'wait' for the result). To send the JSON feedback to the client you can just do 'doJavaScript("...")' from within your C code.

RE: just a simple response from Wt server - Added by alex merge over 8 years ago

Thanks a lot. Works well for me.

RE: just a simple response from Wt server - Added by alex merge over 8 years ago

Hi !

The call

Wt::WApplication::instance()->doJavaScript(tr("user_wdg_menu-user_list").narrow(), true);

user_wdg_menu-user_list - stores JS \" var list_name = 'тест'; \"

causes

[warning] "WString: narrow(): loss of detail: "

Is there any way to pass WString to doJavaScript ?

RE: just a simple response from Wt server - Added by Wim Dumon over 8 years ago

call toUTF8() on the WString instead of narrow().

Wim.

    (1-4/4)