我有 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
}