In the context of a page in SharePoint 2013, I am trying to get items from a list using below code but when the query executes I am getting this error:
SCRIPT5007: Unable to get property 'apply' of undefined or null reference
File: ScriptResource.axd, Line: 5, Column: 298
The response or error functions are never called.
This is the code:
jQuery(document).ready(function() {
// make sure the SharePoint script file 'sp.js' is loaded before code runs
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', retrieveList);
});
function retrieveList() {
var ctx = new SP.ClientContext.get_current();
var list = ctx.get_web().get_lists().getByTitle('ListTitle');
//load list along with it's GUID and Title
ctx.load(list, 'Title', 'Id');
ctx.executeQueryAsync(Function.createDelegate(this,this.RetrievedListID), Function.createDelegate(this, this.ExecutionFailed));
}
//response handler
function RetrievedListID(sender, args) {
var listid = this.list.get_id();
return this.list.get_id();
}
//error handler - generic
function ExecutionFailed(sender, args) {
var listid = "Error";
return args.get_message();
}