Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2023-08

How to add script like the below in pas2js

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Anderson Junior

@Michael Van Canneyt

I apologize, but I forgot an important part of the code that I want to put
in the script, which would be one: setInterval(atualizarTabela, 1000);

getting like this:
<script> // Fun??o para atualizar a tabela function atualizarTabela() { // Fazer uma solicita??o AJAX ao servidor $.ajax({ url: "/api/dados", success: function(dados) { // Atualizar a tabela com os dados recebidos $("#tabela tbody").html(dados); } }); } // Chamar a fun??o a cada segundo setInterval(atualizarTabela,
1000); </script>

Show quoted text 120 lines
Send Pas2js mailing list submissions to To subscribe or unsubscribe via the World Wide Web, visit https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js or, via email, send a message with subject or body 'help' to You can reach the person managing the list at When replying, please edit your Subject line so it is more specific than "Re: Contents of Pas2js digest..." Today's Topics: 1. How to add script like the below in pas2js (Anderson Junior) 2. Re: How to add script like the below in pas2js (Michael Van Canneyt) ---------------------------------------------------------------------- Message: 1 Date: Fri, 25 Aug 2023 13:05:43 -0400 From: Anderson Junior To: Subject: [Pas2js] How to add script like the below in pas2js Message-ID: < > Content-Type: text/plain; charset="utf-8" > > <script> // Fun??o para atualizar a tabela function atualizarTabela() { // > Fazer uma solicita??o AJAX ao servidor $.ajax({ url: "/api/dados", success: > function(dados) { // Atualizar a tabela com os dados recebidos $("#tabela > tbody").html(dados); } }); } I want to add this script to the end of my page to keep updating. Is it possible to do this, or is it better to put it in the html file? -------------- next part -------------- An HTML attachment was scrubbed... URL: < http://lists.freepascal.org/pipermail/pas2js/attachments/20230825/aab11522/attachment-0001.htm > ------------------------------ Message: 2 Date: Fri, 25 Aug 2023 23:17:35 +0200 (CEST) From: Michael Van Canneyt To: Anderson Junior via Pas2js Subject: Re: [Pas2js] How to add script like the below in pas2js Message-ID: Content-Type: text/plain; charset="utf-8"; Format="flowed" On Fri, 25 Aug 2023, Anderson Junior via Pas2js wrote: >> >> <script> // Fun??o para atualizar a tabela function atualizarTabela() { // >> Fazer uma solicita??o AJAX ao servidor $.ajax({ url: "/api/dados", success: >> function(dados) { // Atualizar a tabela com os dados recebidos $("#tabela >> tbody").html(dados); } }); } > > > > I want to add this script to the end of my page to keep updating. > Is it possible to do this, or is it better to put it in the html file? Something like this should work: Procedure UpdateTable; procedure AllOK(d : jsvalue); begin Jquery('#tabela tbody').html(d): end; var opts : TJSobject; begin opts:=TJSObject.New; opts['url']:='/api/dados'; opts['success'; JQuery.Ajax(opt); end; begin UpdateTable; end. ------------------------------ Subject: Digest Footer _______________________________________________ Pas2js maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js ------------------------------ End of Pas2js Digest, Vol 61, Issue 6 *************************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20230826/1b0a395f/attachment.htm>

Reply by email

Luca Olivetti
to Anderson Junior

El 26/8/23 a les 15:22, Anderson Junior via Pas2js ha escrit:

@Michael Van Canneyt I apologize, but I forgot an important part of the code that I want to put in the script, which would be one: setInterval(atualizarTabela, 1000);

You can use a timer, e.g.

   FMyTimer:=TTimer.Create(self);
   ;
   FMyTimer.Interval:=1000;
   FMyTimer.Enabled:=true;

and change the definition of atualizarTabela to

procedure atualizarTabela(sender:TObject)

Bye

Luca

Reply by email