I am facing an issue with my ASP.NET web service that returns a simple string value. I have successfully called this web service using JavaScript and the script manager. However, I am in need of accessing the return value directly from where I made the call to the web service, rather than within the callback function.
I am looking for a solution similar to the following pseudo code:
function retrieveData() {
scriptmanager.webservice.getData(inputParam, handleSuccess);
}
function handleSuccess(returnValue) {
// I want to utilize this return value outside the handleSuccess function
}
I attempted to use a global JavaScript variable outside the functions and assign it in the handleSuccess function, but unfortunately, it always remains undefined in the main "retrieveData" function.
Most examples online focus on updating the visual elements on the page rather than efficiently utilizing the return value from the web service. How can I retrieve the return value back to the main calling function?