title: Passing Value from C++ to Javascript
body: <p>i have a c++ file which reads values from a sensor and I want to display those values on a website dynamically. So Im looking for a way to pass these values(integers) from my cpp file to an javascript which displays them on the site.</p>
  
  <p>My first, simple try was to write the values into a js file as variables every second from my cpp script. The Js then uses this file as a source and displays its variables on the site:</p>
  
  <p>cpp:</p>
  
  <pre><code>fprintf(file, "var mx=%d, my=%d, mz=%d, ax=%d, ay=%d, az=%d, gx=%d, gy=%d, gz=%d;\n",
      imu.raw_m[0], imu.raw_m[1], imu.raw_m[2],       // M = Magnetometer
      imu.raw_a[0], imu.raw_a[1], imu.raw_a[2],       // A = Accelerometer
      imu.raw_g[0], imu.raw_g[1], imu.raw_g[2]        // G = Gyroscope
  );
  </code></pre>
  
  <p>html/js:</p>
  
  <pre><code>&lt;script src="./imu.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>The Problem now is of course, that I need to refresh the page all the time, because the imu.js file is cached by the website.</p>
  
  <p>I'd rather have a way to directly pass to integers from the cpp file to the js script. I read something about json or Googles V8 script. But I'd like to hear your suggestions first.</p>
  
  <p>By the way, Im running this on a raspi, if this is important.</p>
  
  <p>Thanks for your help</p>
  
  <p>EDIT:</p>
  
  <p>I'm goning to try it with a mysql database, in which my cpp file writes the data from the sensor with Connector/c++ from <a href="http://dev.mysql.com/doc/connector-cpp/en/" rel="nofollow">http://dev.mysql.com/doc/connector-cpp/en/</a> and my website reads them.</p>