Jump to content

Recommended Posts

Posted

I am looking for server side method which can invoke a JavaScript function that takes a callback and later asynchronously calls this callback which should result in a server-side call. Basically an async version of existing JSCall method which can take an anonymous function or a delphi callback. Is there such a method already present?

Posted

Hi,

 

If I understand you correctly, you can use ajaxRequest (client side) and OnAjaxEvent (server side)

 

You can find a lot of posts on this topic on the forum

 

Best regards,

Posted

A simple example of what I am looking for:

 

Server-side:

procedure CallBack(AResult: string);
begin
  // Control comes here after timeout
end;

JSAsyncCall('method', CallBack);

Client-side (JS):

method: function(callback) {
  setTimeout(callback, 1000, 'result');
}

I could use ajax to achieve this but I'd have to maintain a mapping on the server of all the callback functions and call them appropriately when the message arrives from the client. I am sure UniGUI must have solved this problem already - so I was looking to see if the framework has something I can use to achieve this.

Posted

I have found an example implementation in UniGUI that may suit what I am looking for. The method "uniGUIDialogs.Prompt" takes a callback function which is called from the client-side once the user dismisses the dialog. Is there something similar which we can use when developing a custom component? How is the the Delphi callback procedure linked to the client-side callback?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...