Jump to content

unitimer do not work in UniMainModule and UniServerModule?


Recommended Posts

Unitimer is client side and unimodule is server side....


in web development the concept is different from regular programming: in web there is the server side who produce the webpage and do the database work... and the client side which is the page you see in the browser...So the timer is js code which run in the client side (in the browser not in the server).
If you wish to run server side code from the timer then use ajax:


Put this code in the timer:

ajaxRequest(MainForm.window, 'myfunc', [] );//in the [] you may pass params

and in the form events "OnAjaxEvent" put this code:

procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string;
  Params: TStrings);
If SameText(EventName, 'myfunc' ) Then
    myfunc;//your procedure or function

and your func declared in the form or in the mainmodule:

procedure TUniMainModule.myfunc;
 showmessage('hello from server side using ajax');

I hope it will help you  :rolleyes:

Link to comment
Share on other sites

Join the conversation

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

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...