I'm writing a Javascript function which will be called by a C# application. I can call the function from C#, but have been unable to retrieve the result of the function.
So I have the following structure:
var B = function() {
var A = function() {
var dfd = new $.Deferred();
// do something and then return the value I need
return dfd.resolve(x);
......
return dfd.promise();
}
$.when(A()).
then(function(x) {
// I can get the x I want here.
alert(x);
// What to do at this point?
});
}
Since A()
used asynchronous methods, I chose to use jQuery.promise()
method to ensure I get the final result of A()
. Now I want B()
to return the value x
to the C# application. Is there any good solution to this?