title: grails refresh a google chart
body: <p>I have a page X in my grails app which has a button to display a chart. It will call a controller with a domain object's id and the chart gets rendered in another page. Till here everything is clear to me.</p>
  
  <p>However I have to <strong>reload</strong> the rendered chart page every 20 seconds. My website is a private one with few admin users only. So I decided to use simple javascript polling to do the refresh.
  This is the snippet in the chart <code>gsp</code> page that I want to reload every 20 seconds. Maybe using javascript <code>setInterval</code>.<br>
  <code>&lt;g:render id="chart" template="/building/${chartTemplate}" model="${model}"&gt;&lt;/g:render&gt;</code></p>
  
  <p>My controller requires a sensor id to be passed in when creating the chart, can I use the java script to do that? If so, how can I get it to the javascript function from the controller which initially redirected it here.</p>
  
  <p>This is my GSP template which renders the chart.</p>
  
  <pre><code>&lt;div id="linechart"&gt;&lt;/div&gt;
  &lt;gvisualization:lineCoreChart dynamicLoading="${true}" elementId="linechart" title="${title}" 
   width="${750}" height="${450}" columns="${columns}" data="${data}"/&gt;
  </code></pre>
  
  <p>Some weird javascript I have used, but not working.</p>
  
  <pre><code>&lt;input type="text" id="sensorid" disabled="disabled" value="${sid }"/&gt;
              &lt;g:javascript&gt;
                  var int=self.setInterval("chart()",1000);
                  var sensid;
                  function chart(){
                      var d=new Date();
                      var t=d.toLocaleTimeString();
                      sensid = document.getElementById("sensorid").value;
                  }
                  ${remoteFunction(controller:"building", action:"createChart", params:"'sid=' + sensid")}
              &lt;/g:javascript&gt;
  </code></pre>
  
  <p>Is there a way in which the javascript can reload the page. Full page reload is also fine. I have near zero knowledge of javascript so any help is highly appreciated.</p>