0

I would like to refresh only one section of the website. It is only one value that I get from Siemens PLC. I receive actual current value, which I want to update on my website.

HTML looks like this:

<table class="tablePowerCurrent">
  <tr>
    <td>
      <p class="Current">:="Var".Point_1.CurrentNow: A</p>
    </td>
      <td>
      <p class="Power">:="Var".Point_1.Power: kWh</p>
    </td>
  </tr>
</table>

Right now I'm doing it with iframes. The table here is placed inside another html, which I use with the iframe in my main html. The iframe has meta refresh.

But now I would like to use script or something similar, to refresh the value.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Sfedo
  • 21
  • 1
  • 8
  • Does this answer your question? [Refresh Part of Page (div)](https://stackoverflow.com/questions/17886578/refresh-part-of-page-div) – mttetc Aug 13 '20 at 08:48

1 Answers1

0

The easiest solution is to place a JS script that will call the Siemens PLC server and get

setInterval(function()
{
  // Update the Current value
   $('.Current').load("https://siemens.com/api/call"); 

  // Update the Power value
   $('.Power').load("https://siemens.com/api/call")
   
}, 100000) // Repeat the refresh every 10sec

Remember that the API call must return a string or a single value because the code will replace the div value in the HTML with the response that will get by that API call (data). Jquery is required

  • seems not to work. Something I'm doing wrong. The :="Var".Point_1.CurrentNow: is what I get from my PLC. when I use it inside my html code I get instead of :="Var".Point_1.CurrentNow: a Value. So I need just to refresh the value or the whole table. – Sfedo Aug 13 '20 at 09:16
  • in that case: try this out $('.Current').html(Var".Point_1.CurrentNow); – Mohamed Ali O.Ameur Aug 13 '20 at 15:52