Page 1 of 1

Custom HTML template, how to refresh data

Posted: Tuesday 20 August 2019 8:53
by zicht
Hi,

I populate a html page in tab custom with lua

Code: Select all

	WriteToFile('<table border="1"><col width="33%"><col width="25%"><col width="32%"><tr><td style="vertical-align:top">'..content..'</td><td style="vertical-align:top">'..weekoverzicht.."</td><td style='vertical-align:top'>"..data.."</td></tr></table>","CustomHTML")
This works great and i have a dynamic custom page with data.
The only problem is how to use HTML code to refresh the table lets day once in 5 minutes

HTML refresh commands cannot been used as it refreshes domoticz as well.
The trick should be in jquery but i have no clue how to start. I tried things by placing the table in a div, but it never refreshes. And then trying to refresh the div.

This snipplet i found on internet, but i have no clue how to adjust

Code: Select all

$.ajax({
  //other options
  success:function(){
       commentContainer.slideUp('slow', function() {$(this).remove();});
       $('#otherdiv').load('urlofpagewith info.html');
  }

 });
Does anybody have the skills and is willing to help to get some jquiry around it ?
Any suggestion is appriciated.

Re: Custom HTML template, how to refresh data

Posted: Tuesday 20 August 2019 12:29
by zicht
Found it finaly content.txt contains the file i compose with lua.
i have made a html page in templates dir that has the below code, it refreshes every minute (60000)
now i can build from that :)

Code: Select all

<div id="mytableHolder">test</div>
<script type="text/javascript">
    $(document).ready(function(){
      refreshTable();
    });

    function refreshTable(){
        $('#mytableHolder').load('/templates/content.txt', function(){
           setTimeout(refreshTable, 60000);
        });
    }
</script>