65.9K
CodeProject is changing. Read more.
Home

Passing parameters to Success method in executeQueryAsync in SharePoint

starIconstarIconstarIconstarIconstarIcon

5.00/5 (2 votes)

Aug 21, 2013

CPOL
viewsIcon

46882

Passing Parameters to Success method in executeQueryAsync.

Introduction

This is quick tip about how to pass parameters and retrieve values from the Success method in executeQueryAsync().

To pass a parameter in Success method use the following syntax:

Before passing parameters:

context.executeQueryAsync(Function.createDelegate(this,this.success)),
 Function.createDelegate(this, this.failed));

After passing parameters:

context.executeQueryAsync(
Function.createDelegate(this,function(){success(_parameter);}),
Function.createDelegate(this, this.failed));
function success(_parameter)
{
    alert(“In Success Method! ” + _parameter);
}

To retrieve values from Success method use the following syntax:

context.executeQueryAsync(
Function.createDelegate(this, function(){ _returnParam = success(_parameter);}),
Function.createDelegate (this, this.failed));
alert(_returnParam);