[Pas2js] How to add script like the below in pas2js

Michael Van Canneyt michael at freepascal.org
Fri Aug 25 23:17:35 CEST 2023



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']:=@AllOK;
   JQuery.Ajax(opt);
end;

begin
   UpdateTable;
end.


More information about the Pas2js mailing list