Automatic Table Records Refresh every X seconds


My app have 2 parts.
- Part 1 (student)
    there are a table records to show the all the questions that user input, with a field "State" (values can be: "Waiting", "Being answered" or "Answered")

    there is a form to input a new question

    after the user input a new question, a new row in the table is created and is shown (ajax refresh), with State = "Waiting"

- Part 2 (professor)
  there is a table record with all new questions from all students.
  after one student input a new question, the table records must update (how?)
  the professor select one question to answer, then, that question's State changes value to "Being Answered", and after thar, I want that the student who made the question can view the state change (their table records uptade) - How to do that?

I know what is the ajax refresh, but I can only use it when the change is made in that side.
If a change is made by other user, how can I automatically syncronize the new state or a new entry?

Hi Mara,

You can have a button (with submit type ajax) on your page that on click executes an action that refreshes the data and the table. This button should be defined with an extended property style="display:none" so it will be invisible.

Then what you can do is to create a javascript function using setInterval that every X seconds triggers a click on that button that in turn would refresh the table.

It could be something like this (for a refresh every 5 seconds):

        $('#" + MyButton.Id + "').trigger('click');
   }, 5000);

Hope this helps,
That does not work!

MyButton = Name of my button, right?

I must put that code that way or I need to put it between <script>  and </script> ?
I tried both and none worked.

Yes, my button does refresh the  table records. It is visible and enabled. When I press it, the table records updates.

In the webscreen proprieties I press the button in the row "JavaScript"
It opens a javascript editor. I put the code there.
Is that right?
The problem here is the MyButton.Id
How can I know that?