Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript get_web() returns NULL

Status
Not open for further replies.

SPDesigns

Programmer
Jun 12, 2012
4
US
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>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top