I'm calling a WebMethod using the ASP .NET AJAX Framework. In the success method, I'm trying to use the return value of the WebMethod. I keep on getting told it's undefined, even though when I'm debugging with Edge I can see that there is a value.
This is the code where I call the WebMethod:
Timebox.CreateNew(timeboxName, timeboxDate, startTime, endTime, CreateTimeboxCallback, CreateTimeboxErrorCallback);
and here is the success callback function:
function CreateTimeboxCallback(response) {
alert(response.d);
}
When I run the code, I get the following messagebox:
When I debug using the browser developer tools, or use console.log(response);, I get the following (which is exactly what the WebMethod is supposed to return):
I want to be able to use the values in ErrorCode and ErrorMessage. Please can someone assist.
if you are getting an error message - is your error callback being called? Also, response is an array [[object Object]]
, so try alerting response[0].ErrorMessage