03-24-2023, 10:24 AM
Ilustres,
Preciso da vossa ajuda na implementação do callback, está retornando o seguinte erro na console do brownser: "Uncaught ReferenceError: ajaxcall is not defined"
Por favor!!!!!!
No formulario HTML:
<script>
function fncExecutarAcao(){
ajaxcall("procEventForm", "params=p1='Param1', p2='param2'");
}
</script>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Meu Perfil</a>
<a class="dropdown-item" href="#">Editar Perfil</a>
<a class="dropdown-item" href="#">Configuração</a>
<a class="dropdown-item" href="#" onclick="fncExecutarAcao();">Sair</a>
</div>
No Delphi:
unit ufrmIndex;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, ufrmPadrao, IWVCLComponent,
IWBaseLayoutComponent, IWBaseContainerLayout, IWContainerLayout,
IWTemplateProcessorHTML, IWApplication, IWTypes, IWBaseComponent,
IWBaseHTMLComponent, IWBaseHTML40Component, IWVCLBaseControl, IWBaseControl,
IWBaseHTMLControl, IWControl, IWCompLabel;
type
TfrmIndex = class(TfrmPadrao)
procedure IWAppFormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure procEventForm(EventParams: TStringList);
end;
var
frmIndex: TfrmIndex;
implementation
{$R *.dfm}
uses ufrmLogin;
{ TfrmIndex }
procedure TfrmIndex.IWAppFormCreate(Sender: TObject);
begin
inherited;
WebApplication.RegisterCallBack('procEventForm', procEventForm);
end;
procedure TfrmIndex.procEventForm(EventParams: TStringList);
var
s1 :TStringList;
I, CountParam :Integer;
S :String;
begin
s1 := TStringList.Create;
CountParam := 0;
try
s1.StrictDelimiter := True;
s1.CommaText := EventParams.Values['params'];
S := s1.CommaText;
CountParam := TStringList(s1).Count;
for I := 0 to pred(CountParam) do
WebApplication.ShowMessage(s1.ValueFromIndex[I]);
finally
s1.Free;
end;
end;
end.
Preciso da vossa ajuda na implementação do callback, está retornando o seguinte erro na console do brownser: "Uncaught ReferenceError: ajaxcall is not defined"
Por favor!!!!!!
No formulario HTML:
<script>
function fncExecutarAcao(){
ajaxcall("procEventForm", "params=p1='Param1', p2='param2'");
}
</script>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Meu Perfil</a>
<a class="dropdown-item" href="#">Editar Perfil</a>
<a class="dropdown-item" href="#">Configuração</a>
<a class="dropdown-item" href="#" onclick="fncExecutarAcao();">Sair</a>
</div>
No Delphi:
unit ufrmIndex;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, ufrmPadrao, IWVCLComponent,
IWBaseLayoutComponent, IWBaseContainerLayout, IWContainerLayout,
IWTemplateProcessorHTML, IWApplication, IWTypes, IWBaseComponent,
IWBaseHTMLComponent, IWBaseHTML40Component, IWVCLBaseControl, IWBaseControl,
IWBaseHTMLControl, IWControl, IWCompLabel;
type
TfrmIndex = class(TfrmPadrao)
procedure IWAppFormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure procEventForm(EventParams: TStringList);
end;
var
frmIndex: TfrmIndex;
implementation
{$R *.dfm}
uses ufrmLogin;
{ TfrmIndex }
procedure TfrmIndex.IWAppFormCreate(Sender: TObject);
begin
inherited;
WebApplication.RegisterCallBack('procEventForm', procEventForm);
end;
procedure TfrmIndex.procEventForm(EventParams: TStringList);
var
s1 :TStringList;
I, CountParam :Integer;
S :String;
begin
s1 := TStringList.Create;
CountParam := 0;
try
s1.StrictDelimiter := True;
s1.CommaText := EventParams.Values['params'];
S := s1.CommaText;
CountParam := TStringList(s1).Count;
for I := 0 to pred(CountParam) do
WebApplication.ShowMessage(s1.ValueFromIndex[I]);
finally
s1.Free;
end;
end;
end.