Reputation: 2724
In my DotNet Core web application I have the following snippet of javascript:
<script type="text/javascript">
setTimeout(function () {
$("#gridContainer").dxDataGrid("refresh");
}, 5000);
</script>
What I want to happen, is every 30 seconds I want my projects datagrid to refresh. I don't want the whole page to reload, only the datagrid. The line that does this is:
$("#gridContainer").dxDataGrid("refresh");
However, when I place it in the setTimeout
this only gets called once. When I want it to be called every 30 seconds.
Could someone please enlighten me as to what I'm doing wrong, and what the best way to achive this would be?
The refresh needs to happen automatically and not on a button press.
Upvotes: 0
Views: 1440
Reputation: 347
For repeating, you should use setInterval():
setInterval(function () {
$("#gridContainer").dxDataGrid("refresh");
}, 5000);
setTimeout(function, milliseconds) -> Executes a function, after waiting a specified number of milliseconds.
setInterval(function, milliseconds) -> Same as setTimeout(), but repeats the execution of the function continuously.
Upvotes: 2