Jump to content

unitimer do not work in UniMainModule and UniServerModule?


uniguibbs

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);
begin
If SameText(EventName, 'myfunc' ) Then
  Begin
    myfunc;//your procedure or function
  End;
end;

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

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

I hope it will help you  :rolleyes:

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...