Welcome! Log In Create A New Profile

Advanced

[WB26] - Auto refresh a page

Posted by JP 
JP
[WB26] - Auto refresh a page
July 29, 2021 04:29PM
Hi All

How do I set a page to auto refresh every N seconds so that it can reflect new data updates on the server?

I have looked at Compatibility: Update browser data from the server every n-seconds but the page does not seem to refresh and not sure what code it runs ?
pao
Re: [WB26] - Auto refresh a page
July 29, 2021 04:35PM
You can do it for instance using TIMER and AJAXEXECUTE

You can find one example provided with webdev for one chat app just take a look at it.

As always this can be done in several ways, check this one to see it's OK for you.

Regards

Paulo Oliveira
JP
Re: [WB26] - Auto refresh a page
July 29, 2021 06:38PM
Paulo

OK, I see the way. Create a procedure and use a procedure timer to refresh the page contents. I thought there might be a setting for the page itself that one could just click on/off but OK, will investigate. Thanks.



Edited 1 time(s). Last edit at 07/29/2021 06:38PM by JP.
JP
Re: [WB26] - Auto refresh a page
July 30, 2021 10:13AM
Hi Paulo

I have been trying various things but cannot get it to work.

1) I looked into AjaxExecute() and when I use this to call a server procedure from browser code to get the new data that works. And in the browser I can update the page controls with the new data.

2) But I cannot see how to do this a continuous loop so that the data is refreshed every N-seconds

3) I cannot find the chat app example in WinDev 26 either.

TIA
pao
Re: [WB26] - Auto refresh a page
July 30, 2021 10:17AM
The example was in V18.

To do it every X seconds use one TIMER in browser code.

Regards

Paulo Oliveira
JP
Re: [WB26] - Auto refresh a page
July 30, 2021 10:36AM
Paulo

Thanks. I have it working with the Timer() function. So I have:

1) In the Page Load - Onload Browser Event I use Timer() to call a browser procedure.

2) The Browser procedure then calls a server function using AjaxExecute to retrieve the new data.

3) Then the Browser procedure updates the specific controls required with the new data.

Does that make sense? It seems to work smiling smiley
Re: [WB26] - Auto refresh a page
July 30, 2021 02:24PM
Hi all

Ideally, you do something like this with websockets...
Also a standard feature of V26.

Cheers

Peter H.



Edited 1 time(s). Last edit at 07/31/2021 03:50PM by PeHoBe.
Argus
Re: [WB26] - Auto refresh a page
July 30, 2021 02:24PM
it is the correct logic BUT

1. you should use ajaxexecuteasynchronous to do the refresh, in order to avoid blocking your customer during the dialog with the server (very fast in test, not so much in production)
2. you should test on the server side if there is anything new and decide if you do a refresh or not, as you do not want to refresh a page with the exact same data.
JP
Re: [WB26] - Auto refresh a page
July 30, 2021 04:17PM
Argus

Yes, agree and have done those 2 things. Thanks smiling smiley

Cheers
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: