SP へClientContext.executeQueryAsync 方法 (sp.js)
Executes the current pending request asynchronously on the server.
**適用対象:**apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013
SP.ClientContext.executeQueryAsync(succeededCallback, failedCallback)
パラメーター
succeededCallback
A function or a delegate of the method to call if the request executes successfully.failedCallback
A function or a delegate of the method to call if the request fails to execute.
Remarks
The executeQueryAsync method is inherited from the SP.ClientRuntimeContext object. This virtual method is asynchronous, which means that the code will continue to be executed without waiting for the server to respond.
例
The following code example shows how to use the executeQueryAsync method.
function retrieveWebSite(siteUrl) {
var clientContext = new SP.ClientContext(siteUrl);
this.oWebsite = clientContext.get_web();
clientContext.load(this.oWebsite);
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed)
);
}
function onQuerySucceeded(sender, args) {
alert('Title: ' + this.oWebsite.get_title() +
' Description: ' + this.oWebsite.get_description());
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() +
'\n' + args.get_stackTrace());
}