When trying to execute the following code i got the mentioned error. Here is the snippet:
var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
clientContext.load(web);
clientContext.executeQueryAsync(Get, Failed);
function Get()
{
alert(web.get_url());
}
function Failed()
{
alert('Failed' + args.get_message());
}
I've tried it on root site (/sites/root) and subsite (/sites/root/subsite/), still the same.
Thanks.
UPD
When trying to execute this snippet:
var clientContext = new SP.ClientContext.get_current();
console.log(clientContext)
var web = clientContext.get_web()
console.log(web)
var subsites = web.get_webs();
console.log(subsites)
clientContext.load(subsites);
clientContext.executeQueryAsync(function(s, a)
{
var userInfo = [];
var siteenum = subsites.getEnumerator();
while (siteenum.moveNext())
{
var oweb = siteenum.get_current();
var webtitle = oweb.get_title();
userInfo.push(webtitle);
}
console.log(userInfo.join(''));
}
);
i got the following:
SP.ClientContext {$r_0: Object, $1P_0: "/sites/root", $1O_0: Object, $8_0: SP.ClientRequest, $O_1: SP.Web…} SP.Web {$0_0: SP.ClientContext, $4_0: SP.ClientObjectData} SP.WebCollection {$0_0: SP.ClientContext, $4_0: SP.ClientObjectData}
site1 site2 site3
But when adding
var weburl = oweb.get_url();
userInfo.push(webtitle + weburl);
The error is still the same:
Uncaught TypeError: oweb.get_url is not a function