Partager via


Generated Proxy Classes Succeeded Callback Function

Called to process returned data after a Web service method request has finished successfully.

Note

The succeeded callback function can have any name.

function SucceededCallback(result, userContext, methodName)
{
    // Code here to process results from the Web service call.
}

Parameters

Parameter

Definition

result

The data returned from the Web service method call. This is a JavaScript object whose type corresponds to the .NET Framework type returned by the Web method.

userContext

The context information that was passed when the Web service method was invoked. If the context information is not passed, the defaultUserContext object is used, if defined; otherwise null is passed to the callback function. The userContext value provides additional information that you can use to process the returned data.

methodName

The Web service method that was invoked. The methodName parameter provides additional information to use when you process the returned data.

Remarks

The succeeded callback function is a JavaScript function that you provide to process the returned data after a Web service request finishes successfully.

You can assign the callback function to the generated proxy class or its instances by using the defaultSucceededCallback property. Alternatively, you can pass the callback function when you call a Web service method. This overrides the default value.

Example

The following example shows how to define a succeeded callback function.

// Callback function invoked when a call to 
// the Web service methods succeeds.
function SucceededCallback(result, userContext, methodName)
{ 
    var message;
    switch(methodName)
    {
        case ("GetDefaultColor"):
        case ("SetColor"):
        {
            // Get the server default color.
            message = result.message;
            defaultRgb = result.rgb;


            // Transform the rgb array into a string.
            var serverColor = defaultRgb[0]+ defaultRgb[1] + defaultRgb[2];

            // Display the result.
            displayResult.style.color = "yellow";
            displayResult.style.fontWeight = "bold";
            displayResult.style.backgroundColor = "#" + serverColor;
            DisplayMessage(message);
            break;
        }
        default:
        {
            DisplayMessage("Method unknown");
        }
    }       
}

See Also

Reference

Generated Proxy Classes defaultUserContext Property

Generated Proxy Classes defaultFailedCallback Property

Concepts

Sys.Net.WebServiceProxy Class

Other Resources

Generated Proxy Classes defaultSucceededCallback Property