Share via


Ewa.AsyncResult Object

Applies to: apps for SharePoint | SharePoint Server 2010

Contains the result of the asynchronous operation and is passed as the first argument to the specified callback.

Ewa.AsyncResult

Remarks

AsyncResult contains information about the asynchronous operation, including any error code, error message, whether or not the operation succeeded, return values, and state information.

In the JavaScript object model for Excel Services in Microsoft SharePoint Server 2010, all methods that have a method name that is appended with "Async" (for example, Workbook.getRangeA1Async) use an AsyncResult object as an argument in the call to the specified callback method. You use the methods of the AsyncResult object to get information about the asynchronous operation.

Example

The following code example shows how to use the AsyncResult object to obtain the return value and state information that resulted from the call to the getRangeA1Async method.

<script type="text/javascript">

var ewa = null;

// Add event handler for onload event.
if (window.attachEvent) 
{ 
    window.attachEvent("onload", ewaOmPageLoad);    
} 
else 
{ 
    window.addEventListener("DOMContentLoaded", ewaOmPageLoad, false); 
}
// Add event handler to the applicationReady event.
function ewaOnPageLoad()
{
    if (typeof (Ewa) != "undefined")
    {
       Ewa.EwaControl.add_applicationReady(ewaApplicationReady);
    }
    else
    {
       alert("Error - the EWA is not loaded.");
    }
    // Add your code here.
}

function ewaApplicationReady()
{
    // Get a reference to the Excel Services Web Part.
    ewa = Ewa.EwaControl.getInstances().getItem(0);

    // Add your code here.
}

function someFunction()
{
   // Add your code here.
   ewa.getActiveWorkbook().getRangeA1Async("Sheet2!B2", getRangeComplete, userContext);
   // Add other code here.
}
function getRangeComplete(asyncResult)
{
    if (asyncResult.getSucceeded())
    {
        // Gets the value in "Sheet2!B2".
        var range = asyncResult.getReturnValue();
        // Gets the value of the argument passed in 
        // for the userContext parameter in getRangeA1Async.
        var value = asyncResult.getUserContext();
    }
    // Add your code here.
}

</script>

See Also

Reference

Ewa.AsyncResult Methods