<div dir="ltr"><div dir="ltr">@Michael Van Canneyt<br></div><div dir="ltr"><br></div><div dir="ltr">I apologize, but I forgot an important part of the code that I want to put in the script, which would be one: <span class="gmail-hljs-built_in" style="font-family:"Google Sans Mono",monospace;font-size:14px;white-space:pre;background-color:rgb(248,250,253)">setInterval</span><span style="color:rgb(68,71,70);font-family:"Google Sans Mono",monospace;font-size:14px;white-space:pre;background-color:rgb(248,250,253)">(atualizarTabela, </span><span class="gmail-hljs-number" style="font-family:"Google Sans Mono",monospace;font-size:14px;white-space:pre;background-color:rgb(248,250,253)">1000</span><span style="color:rgb(68,71,70);font-family:"Google Sans Mono",monospace;font-size:14px;white-space:pre;background-color:rgb(248,250,253)">);</span><br></div><div dir="ltr"><span style="color:rgb(68,71,70);font-family:"Google Sans Mono",monospace;font-size:14px;white-space:pre;background-color:rgb(248,250,253)"><br></span></div><div dir="ltr">getting like this:<span style="color:rgb(68,71,70);font-family:"Google Sans Mono",monospace;font-size:14px;white-space:pre;background-color:rgb(248,250,253)"><br></span></div><div dir="ltr"><span class="gmail-hljs-tag" style="color:rgb(68,71,70);font-family:"Google Sans Mono",monospace;font-size:14px;white-space:pre"><<span class="gmail-hljs-name">script</span>></span><span class="gmail-javascript" style="color:rgb(68,71,70);font-family:"Google Sans Mono",monospace;font-size:14px;white-space:pre">
  <span class="gmail-hljs-comment">// Função para atualizar a tabela</span>
  <span class="gmail-hljs-function"><span class="gmail-hljs-keyword">function</span> <span class="gmail-hljs-title">atualizarTabela</span>(<span class="gmail-hljs-params"></span>) </span>{
    <span class="gmail-hljs-comment">// Fazer uma solicitação AJAX ao servidor</span>
    $.ajax({
      <span class="gmail-hljs-attr">url</span>: <span class="gmail-hljs-string">"/api/dados"</span>,
      <span class="gmail-hljs-attr">success</span>: <span class="gmail-hljs-function"><span class="gmail-hljs-keyword">function</span>(<span class="gmail-hljs-params">dados</span>) </span>{
        <span class="gmail-hljs-comment">// Atualizar a tabela com os dados recebidos</span>
        $(<span class="gmail-hljs-string">"#tabela tbody"</span>).html(dados);
      }
    });
  }

  <span class="gmail-hljs-comment">// Chamar a função a cada segundo</span>
  <span class="gmail-hljs-built_in">setInterval</span>(atualizarTabela, <span class="gmail-hljs-number">1000</span>);
</span><span class="gmail-hljs-tag" style="color:rgb(68,71,70);font-family:"Google Sans Mono",monospace;font-size:14px;white-space:pre"></<span class="gmail-hljs-name">script</span>></span><br></div><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Em sáb., 26 de ago. de 2023 às 06:00, <<a href="mailto:pas2js-request@lists.freepascal.org">pas2js-request@lists.freepascal.org</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Send Pas2js mailing list submissions to<br>
        <a href="mailto:pas2js@lists.freepascal.org" target="_blank">pas2js@lists.freepascal.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js" rel="noreferrer" target="_blank">https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js</a><br>
or, via email, send a message with subject or body 'help' to<br>
        <a href="mailto:pas2js-request@lists.freepascal.org" target="_blank">pas2js-request@lists.freepascal.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:pas2js-owner@lists.freepascal.org" target="_blank">pas2js-owner@lists.freepascal.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Pas2js digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. How to add script like the below in pas2js (Anderson Junior)<br>
   2. Re: How to add script like the below in pas2js<br>
      (Michael Van Canneyt)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Fri, 25 Aug 2023 13:05:43 -0400<br>
From: Anderson Junior <<a href="mailto:andersonscinfo@gmail.com" target="_blank">andersonscinfo@gmail.com</a>><br>
To: <a href="mailto:pas2js@lists.freepascal.org" target="_blank">pas2js@lists.freepascal.org</a><br>
Subject: [Pas2js] How to add script like the below in pas2js<br>
Message-ID:<br>
        <<a href="mailto:CAAFh3a0ucADqV5T%2BtyjO4bqd0DehTgJWtLKGpXXOVR2vGYBsoA@mail.gmail.com" target="_blank">CAAFh3a0ucADqV5T+tyjO4bqd0DehTgJWtLKGpXXOVR2vGYBsoA@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
><br>
> <script> // Fun??o para atualizar a tabela function atualizarTabela() { //<br>
> Fazer uma solicita??o AJAX ao servidor $.ajax({ url: "/api/dados", success:<br>
> function(dados) { // Atualizar a tabela com os dados recebidos $("#tabela<br>
> tbody").html(dados); } }); }<br>
<br>
<br>
<br>
I want to add this script to the end of my page to keep updating.<br>
Is it possible to do this, or is it better to put it in the html file?<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.freepascal.org/pipermail/pas2js/attachments/20230825/aab11522/attachment-0001.htm" rel="noreferrer" target="_blank">http://lists.freepascal.org/pipermail/pas2js/attachments/20230825/aab11522/attachment-0001.htm</a>><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Fri, 25 Aug 2023 23:17:35 +0200 (CEST)<br>
From: Michael Van Canneyt <<a href="mailto:michael@freepascal.org" target="_blank">michael@freepascal.org</a>><br>
To: Anderson Junior via Pas2js <<a href="mailto:pas2js@lists.freepascal.org" target="_blank">pas2js@lists.freepascal.org</a>><br>
Subject: Re: [Pas2js] How to add script like the below in pas2js<br>
Message-ID: <<a href="mailto:a71e95e4-6bd7-30db-23bf-1a387cfcefdc@freepascal.org" target="_blank">a71e95e4-6bd7-30db-23bf-1a387cfcefdc@freepascal.org</a>><br>
Content-Type: text/plain; charset="utf-8"; Format="flowed"<br>
<br>
<br>
<br>
On Fri, 25 Aug 2023, Anderson Junior via Pas2js wrote:<br>
<br>
>><br>
>> <script> // Fun??o para atualizar a tabela function atualizarTabela() { //<br>
>> Fazer uma solicita??o AJAX ao servidor $.ajax({ url: "/api/dados", success:<br>
>> function(dados) { // Atualizar a tabela com os dados recebidos $("#tabela<br>
>> tbody").html(dados); } }); }<br>
><br>
><br>
><br>
> I want to add this script to the end of my page to keep updating.<br>
> Is it possible to do this, or is it better to put it in the html file?<br>
<br>
<br>
Something like this should work:<br>
<br>
<br>
Procedure UpdateTable;<br>
<br>
     procedure AllOK(d : jsvalue);<br>
<br>
     begin<br>
       Jquery('#tabela tbody').html(d):<br>
     end;<br>
<br>
var<br>
   opts : TJSobject;<br>
<br>
begin<br>
   opts:=TJSObject.New;<br>
   opts['url']:='/api/dados';<br>
   opts['success']:=@AllOK;<br>
   JQuery.Ajax(opt);<br>
end;<br>
<br>
begin<br>
   UpdateTable;<br>
end.<br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
_______________________________________________<br>
Pas2js maillist  -  <a href="mailto:Pas2js@lists.freepascal.org" target="_blank">Pas2js@lists.freepascal.org</a><br>
<a href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js" rel="noreferrer" target="_blank">https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js</a><br>
<br>
<br>
------------------------------<br>
<br>
End of Pas2js Digest, Vol 61, Issue 6<br>
*************************************<br>
</blockquote></div></div>