I'm having a tough time getting the result from my controller, it has a function that contains a delegate funciont passint as a parameter.

so the result is awais empty and then goes back after its finished.

HTLM

<label>"Name:"</label>
<input id="txtName" type="text"/>;
<label>"lastName:"</label>;
<input id="txtlastName" type="text"/>

<button onclick="SayHello()">HELLO</button>


JS

<pre lang="Javascript">

function SayHello() {
var user = CaptureElements();
var json = JSON.stringify(user);
var url = '@Url.Action("SayHello&amp", "Home")';

$.ajax({
url: url,
async: false,
data: json,
type: 'POST',
contentType: 'application/json',
dataType: 'json',
success: function (data) {
$("#aaa")[0].innerHTML = data;
alert(data);
}
});


function CaptureElements() {
var name = document.getElementById(&quot;txtName&quot.value;
var lastname = document.getElementById(&quot;txtlastName&quot.value;
return (name == &quot;&quot; ? null : { name: name, lastname: lastname })

}
</pre>


C#

<pre lang="c#">

[HttpPost]
public ActionResult SayHello(Usuario user)
{
var Proxy = content();
string hello= "";
Proxy.SayHello(user.name.ToString(), user.lastName.ToString(),
(String result) =>
{
hello= result;

}, ExceptionCallback);

return Json(hello);
}


</pre>

CSharp / DataSnap

The "Proxy" class below was generated by delphi xe5 data snap project.

http://docwiki.embarcadero.com/RADSt...bile_Connector

<pre lang="c#">

/**
* @param FirstName [in] - Type on server: string
* @param LastName [in] - Type on server: string
* @return result - Type on server: string
*/
public delegate void SayHelloCallback(String Result);

public void SayHello(String FirstName, String LastName, SayHelloCallback callback = null, ExceptionCallback ExCal = null)
{
DSRESTCommand cmd = getConnection().CreateCommand();
cmd.setRequestType(DSHTTPRequestType.GET);
cmd.setText("TServerMethods1.SayHello");
cmd.prepare(get_TServerMethods1_SayHello_Metadata());
InternalConnectionDelegate SayHelloDel = () =>
{
if (callback != null)
{
try
{
callback.DynamicInvoke(cmd.getParameter(2).getValue().GetAsString());
}
catch (Exception ex)
{
if (ExCal != null) getConnection().syncContext.Send(new SendOrPostCallback(x => ExCal.DynamicInvoke(ex.InnerException)), null);
else getConnection().syncContext.Send(new SendOrPostCallback(x => BaseExCal.DynamicInvoke(ex.InnerException)), null);
}
}
};
cmd.getParameter(0).getValue().SetAsString(FirstName);
cmd.getParameter(1).getValue().SetAsString(LastName);
getConnection().execute(cmd, this, SayHelloDel, ExCal);
}


</pre>


I would really appreciate any help!
Thansk.