hi,
I am creating the sharepoint hosted app, for sharepoint online using Nappa tool, trying to fetch the web property for the hosted web application, on debugging the following code using developer tool, it throws the exception clientcontext object is undefined and then "Access denied' , Host url is returned correctly.
'use strict';
var hostweburl; var clientContext; $(document).ready(function () { hostweburl = decodeURIComponent( getQueryStringParameter("SPHostUrl")); alert(hostweburl); createHostWebURLofAPP(); }); function createHostWebURLofAPP() { clientContext= new SP.ClientContext(hostweburl); this.oWebsite = clientContext.get_web(); clientContext.load(this.oWebsite); // throws exception // alert(hostweburl); clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed); //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()); } function getQueryStringParameter(paramToRetrieve) { var params = document.URL.split("?")[1].split("&"); var strParams = ""; for (var i = 0; i < params.length; i = i + 1) { var singleParam = params[i].split("="); if (singleParam[0] == paramToRetrieve) return singleParam[1]; } }
any pointer why it is throwing exception
thanks
regards Vimal