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
Show quoted text 5 lines
<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.htm>

Michael Van Canneyt
to Anderson Junior
Anderson Junior wrote 10 lines
> > <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.