Kattes Posted April 24 Share Posted April 24 Hi everyone, I'm currently working on a UniGUI project where I need to make an AJAX call from JavaScript code within a TUniHTMLFrame component. I've been trying to set up the AJAX call using ajaxRequest, but I'm encountering difficulties in properly referencing the component to trigger the event handler on the server side. Here is some code, which works fine in a standalone project - but I am not able to transfer this to my component code: procedure TMainForm.UniFormCreate(Sender: TObject); begin UniHTMLFrame1.HTML.Text := '<!DOCTYPE html>' + '<html>' + '<head>' + '<title>Button Test</title>' + '<script type="text/javascript">' + 'function buttonClicked() {' + ' ajaxRequest(MainForm.UniHTMLFrame1, "buttonClick", ["info=Ajax works fine!"]);' + '}' + '</script>' + '</head>' + '<body>' + '<button onclick="buttonClicked()">Click Me!</button>' + '</body>' + '</html>'; end; procedure TMainForm.UniHTMLFrame1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = 'buttonClick' then begin ShowMessage('Button was clicked with info: ' + Params.Values['info']); end; end; Despite my efforts, I haven't been able to get the AJAX call to work as expected. I've explored various approaches, including using window.parent, window.parent.Ext.getCmp, and direct references to the component's JSName, but none of them seem to be yielding the desired results. Could someone please provide guidance on how to correctly set up the AJAX call within a TUniHTMLFrame component? Any insights or alternative approaches would be greatly appreciated. Thanks in advance for your help! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 24 Share Posted April 24 Hello @Kattes Also try with top.MainForm..., top.ajaxRequest... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.