We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

load view every x seconds with Java Script

Hi, I want to refresh a table with data from the database every 30 seconds. I tried to embed a view into a view while calling an action with JQuery.load(). But it does not work :( . My Code looks like this:

<div id="flashAlert">
    <script>
        var Data = {
            id: "{{ id }}"
        };
        setIntervall($('#flashAlert').load("someUrl", Data, function (responseTxt, statusTxt)), 5000);
    </script>
</div>

The Route "someUrl" works and the view is rendered correct.

You doesn't do anything with retruned response....



1.1k

Yes you are right. I tried this just to check if I am able to load a volt view into a volt view but this also does not work ....

$('#flashAlert').load("/someUrl/", data, function(responseTxt, StatusTxt) {
              document.getElementById("flashAlert").innerHTML = responseTxt;

          });


1.1k

I have found the solution:

function getOrders() {
              $('#flashAlert').load("url", data);
          }

          window.setInterval("getOrders()",30000);