Project

General

Profile

Request data in javascript code from server, c++

Added by Sander Denorme almost 4 years ago

Hi,

I am trying to request data in my javascript code from the server side, c.

I know you can send a signal from the client side with JSignal to the server side, but can you add a response to this event?

Or what is the best way to send data from the server side to the client side?

Thank you


Replies (4)

RE: Request data in javascript code from server, c++ - Added by Roel Standaert almost 4 years ago

You can add arguments to the signal. You could for example use a JSignal<std::string> and send JSON as a string. That's the simplest way, I think.

Unless I'm misunderstanding what you're looking for?

RE: Request data in javascript code from server, c++ - Added by Sander Denorme almost 4 years ago

Hi,

With adding arguments to the signal, you can send data from the client to the server. But is there a way to send data from the server to the client side?

For example:

Ajax Get call from the client to a wt endpoint and respond to such a call. Is this possible in wt?

RE: Request data in javascript code from server, c++ - Added by Roel Standaert almost 4 years ago

Oh ok. You may be looking for WResource if you want to handle arbitrary requests, or for "server push": the ability for the server to send updates to the client without a corresponding event from the client.

From your first post, it seemed that you just wanted to respond to a JSignal, which is just simply done by connecting a slot and updating your widgets.

RE: Request data in javascript code from server, c++ - Added by Sander Denorme almost 4 years ago

Hi,

Thank you very much! This was what I was looking for!

    (1-4/4)