Feature Request : Add Abillity To Send Message To XOJO Backend Webserver From Javascript Running In Browser

Sometimes we use javascript to manipulate XOJO objects in the browser.
Like moving the controls freely using drag and drop via jQuery.
But there is no way to update the parameters ( e.g. : location ) to the
backend server. So whenever the parameter is updated, it will return to the value last
maintained by the backend server. I utilize JavaScriptError event
to return values from the webpage to the backend server but this is not supposed to be handled like this.
Can we have an event like MessageFromJavascript / JavascriptMessage / or whatever suitable
to allow this? It will simplify development greatly without having to resort to WebSDK etc.

Please consider this. :slight_smile:

https://tracker.xojo.com/xojoinc/xojo/-/issues/77072

You should really look at the WebSDK. there are several examples of how to do just what you are asking for.

Check out the quick start and I bet you could create a generic control that would work in all cases for you.

2 Likes

about Javascript
maybe you can use the Fetch API, a method called fetch can send data to backend.
for input forms there is FormData helpful.
and have a look at JavaScript HTML Document Object Model (DOM)

You could also use App.HandleUrl for this.

2 Likes

I also think it’s much easier to just use the Web SDK in this case.

4 Likes

I respectfully disagree to that.

If you need a quick way to track the movement of say, 15 instances of 10 different types
of container controls in a single web page, it would be quite cumbersome to implement
them as Web Sdk controls. I have about 20 unique container controls and encapsulating them
as Web Sdk control at this stage is not feasible.

Xojo has an identical implementation (the JavaScript Error event.) I though you might just be able to duplicate one for non-error related notification.

But anyway its a feature request. I can live with the hack for now.
Please keep up with the good work and i look forward to Release 3.

1 Like

But you don’t need one sdk control per container. You could have a single control per page that you use for transmitting data about all of the controls. The WebSDK has a super easy mechanism for transmitting data from the page and having it fire an event in a control already. All you’d need to do is create a json string that contained the controlID and the new position and size. When you get the event, you find the control by the controlID and set its values.

But hey, what could the guy who created the WebSDK (that’s me) and the guy who’s now maintaining the web framework (Ricardo) possibly know about the easiest way to solve your problem…

5 Likes

Just FYI - what I just described is in fact one of the WebSDK example files. Look in the Extras folder next to the IDE, there’s a folder called WebSDK and another inside called Examples. The project you’re looking for is called “Callback Example”

3 Likes

Thanks for the lead Greg. I ll look into this. :+1: