我有jquery ajax调用servicestack服务。 servicestack服务调用服务器端的异步方法。 这是场景;
我的服务保存数据并返回没问题的返回对象。
但我需要从异步方法获取响应到jquery客户端
怎么做?请帮忙......
public class MyService : Service
{
public GenericResponse Any(EditRequest request)
{
GenericResponse result = new GenericResponse();
_repo.Do(request.data, "add");
result.hasMessage = true;
result.message.messageType = Enums.MessageTypes.Success;
result.message.messageData = "save success";
return result;
}
}
//_repo methods
public void Do(object data, string oper)
{
WEBBeanClient client = new WEBBeanClient();
client.BeginInsert(data, username, password, callback, client);
}
private void callback(IAsyncResult asyncResult)
{
var client = asyncResult.AsyncState as WEBBeanClient;
var result= client.EndInsert(asyncResult);
// need to get return here to jquery client
}