Hello everyone,
I am trying to use the Javascript client object model scripting on my SharePoint site. I have owner priveledges for one of the site collection, where I am working. I am performing very basic run to get started. Please see my code below.
It gets the the correct context \sites\mysite, but the get_web() returns NULL. I don't understand why this could be a problem.
Any suggestions would be great help. I found this script being used everywhere on the web, so not sure what I am doing wrong here.
Thanks.
<SharePoint:ScriptLink ID="ScriptLink1" Name="SP.js" runat="server" OnDemand="true" Localizable="false" />
<SharePoint:FormDigest ID="FormDigest1" runat="server" />
<script type="text/javascript">
alert("here");
ExecuteOrDelayUntilScriptLoaded(GetList, "sp.js");
function GetList()
{
alert("now here");
var currentcontext = new SP.ClientContext.get_current();
this.web = currentcontext.get_web();
currentcontext.load(this.web);
currentcontext.executeQueryAsync(Function.createDelegate(this, this.ExecuteOnSuccess),Function.createDelegate(this, this.ExecuteOnFailure));
alert("HERE");
};
function ExecuteOnSuccess(sender, args) {
alert("success");
};
function ExecuteOnFailure(sender, args) {
alert("Error in Getting List ID");
};
</script>
I am trying to use the Javascript client object model scripting on my SharePoint site. I have owner priveledges for one of the site collection, where I am working. I am performing very basic run to get started. Please see my code below.
It gets the the correct context \sites\mysite, but the get_web() returns NULL. I don't understand why this could be a problem.
Any suggestions would be great help. I found this script being used everywhere on the web, so not sure what I am doing wrong here.
Thanks.
<SharePoint:ScriptLink ID="ScriptLink1" Name="SP.js" runat="server" OnDemand="true" Localizable="false" />
<SharePoint:FormDigest ID="FormDigest1" runat="server" />
<script type="text/javascript">
alert("here");
ExecuteOrDelayUntilScriptLoaded(GetList, "sp.js");
function GetList()
{
alert("now here");
var currentcontext = new SP.ClientContext.get_current();
this.web = currentcontext.get_web();
currentcontext.load(this.web);
currentcontext.executeQueryAsync(Function.createDelegate(this, this.ExecuteOnSuccess),Function.createDelegate(this, this.ExecuteOnFailure));
alert("HERE");
};
function ExecuteOnSuccess(sender, args) {
alert("success");
};
function ExecuteOnFailure(sender, args) {
alert("Error in Getting List ID");
};
</script>