Jump to content

Calling a server side function from HTMLFrame


Guest

Recommended Posts

Message from: "fbarley"

 

I am using HTML Frame with great success in testing. Now I need to hook

up some server side logic to the user inputs in the HTMLFrame.

 

How do I set up a Ext.Ajax.request({url:"mydll/HandleEvent"... on the

client and server side to handle HTMLFrame coordination? Or is there a

better way?

.

 

Link to comment
Share on other sites

Message from: "Farshad Mohajeri"

 

"fbarley" wrote in message

news:m0SsKW5mLHA.2080@anaxagvs227...

>I am using HTML Frame with great success in testing. Now I need to hook up

>some server side logic to the user inputs in the HTMLFrame.

>

> How do I set up a Ext.Ajax.request({url:"mydll/HandleEvent"... on the

> client and server side to handle HTMLFrame coordination? Or is there a

> better way?

 

Interaction between ClientSide JavaScript code and server handlers is not

implemented yet. It is planned to be implemented in one of the 0.8x

releases. That said, you can use JS code to call one of the "existing" AJAX

handlers.

 

 

.

 

Link to comment
Share on other sites

Message from: "Junior/RO"

 

Farshad Mohajeri escreveu:

 

> That said, you can use JS code to call one of the "existing" AJAX handlers.

 

Can you give us a example of this?

 

--

Que é essa vida se, com tanto a fazer, não temos tempo para parar e ver?

.

 

Link to comment
Share on other sites

Message from: "Farshad Mohajeri"

 

"Junior/RO" wrote in message =

news:tz07aOJnLHA.2084@anaxagvs227...

> Farshad Mohajeri escreveu:

>=20

>> That said, you can use JS code to call one of the "existing" AJAX =

handlers.

>=20

> Can you give us a example of this?

>=20

 

Consider you have a UniButton1 on form and it has a click event.

 

In UniHTMLFrame BeforeScript property:

 

function AjaxSuccess(response){

try{

eval(response.responseText);

}

catch(err){

AjaxError(err.message+"

"+response.responseText);

}

};

 

function buttonClick(Btn) {

=

Ext.Ajax.request({url:"/HandleEvent",params:"Ajax=3D1&Ajax=3D1&IsEvent=3D=

1&Obj=3D"+

=

Btn.nm+"&Evt=3Dclick&This=3D"+Btn.nm+_gv_(O0),success:AjaxSuccess,failure=

:{},obj:Btn});

}; =20

 

In Form OnShow event:

 

procedure TMainForm.UniFormShow(Sender: TObject);

begin

if WebMode then

begin

UniHTMLFrame1.HTML.Text:=3D'

id=3D"button1"'+

' =

onclick=3D"buttonClick('+TUniExtButton(UniButton1).ExtControl.JSName+')" =

value=3D"HTML Button" />';

end;

end;

 

Pressing HTML button will call UniButton1 event.

 

Link to comment
Share on other sites

  • 4 years later...

1.
UniSession.AddJS('$.ajax({'
    + 'url: "' + UniSession.CallbackUrl('$.ajax', self, []) + '",'
    + 'type: "POST",'
    + 'data: {username:"g", abc:123},'
    + 'dataType: "text",'
    + 'success: function(data){'
    + '  alert("OK!"+data);'
    + '  }'
    + '});');
procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string;Params: TStrings);
begin
if EventName = '$.ajax' then
  begin
    UniEdit1.Text := 'AAAAAAA';    //Execution is not successful(Show no change)。  showmessage(UniEdit1.Text);(Display results correctly)         This is why?
    UniSession.AResponse.ContentText := '{"success":true,"manager":[{"name":"xxx","userId":"222"},{"name":"yyy","userId":"333"}]}';
  end;
end;

 

2.
unisession.AddJS('ajaxRequest(MainForm.window,"ajaxRequest",[]);');
procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string;Params: TStrings);
begin
if EventName = 'ajaxRequest' then
  begin
    UniEdit1.Text := 'AAAAAA';     //Execution is successful(Show change)
    UniSession.Response := 'Ext.Msg.alert("","ok!");';
  end;
end;

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...