Javascript with Sharepoint

I'm trying to follow the examples in this article:

I'm having a hard time with the first examples.  I'm trying to run the following code.

Retrieve only selected properties of a website

/// <reference path="//>

/// <reference path="//"/>

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()); } 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) ); }

Nothing seems to happen.  I'm relatively new to JavaScript and I assume this is failing somewhere in the code since there is no return at all.

I'm using Visual Studio and put in the references as mentioned in the article in a JS file and added it.  In the web part I reference my JS Script as well as the jquery and ajax.js. 

I can get the first example to work.  The example above is confusing me because it looks like it should work.

Anyone have insight for a newb?

July 17th, 2015 10:49am

When stepping through the code writing it one line at a time I don't seem to have all the references maybe.


Function.createDelegate(this, this.onQuerySucceeded)
Function doesn't have a "createDelegate".

Free Windows Admin Tool Kit Click here and download it now
July 17th, 2015 10:55am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics