1

I'm trying to make a JavaScript query on SharePoint 2010 via the following code.

On query success I got no problem, but if query fails I get "args is undefined".

All examples I see works same way I do, but I don't understand why I'm getting this error.

 function getEspais(url) {
   this.clientContext = new SP.ClientContext(url);
   this.collNavNode = clientContext.get_web();
   this.subWebs = this.collNavNode.get_webs();
   clientContext.load(this.subWebs);
   clientContext.executeQueryAsync(
     Function.createDelegate(this, function(){ _returnParam = successEspais(); }),
     Function.createDelegate(this, function(){ _returnParam = onQueryFailed(); })
   );
 }

 function successEspais(sender, args) {
     // Works perfectly!
 }

 function onQueryFailed(sender, args) {
    // Getting error 'args is undefined'    
    alert('Consulta fallida. ' + args.get_message() + '\n' + args.get_stackTrace());
 }

1 Answer 1

1

Try your code like:

clientContext.executeQueryAsync(successEspais, onQueryFailed);

function successEspais(sender, args) {
     // Works perfectly!
}

function onQueryFailed(sender, args) {
    // Getting error 'args is undefined'    
    alert('Consulta fallida. ' + args.get_message() + '\n' + args.get_stackTrace());
}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.