I am using this code:
"use strict"
var BasicJSOM = window.BasicJSOM || {};
BasicJSOM.Crud = BasicJSOM.Crud || {};
$(function() {
BasicJSOM.Crud.MainDemo = new BasicJSOM.Crud.Main();
SP.SOD.executeOrDelayUntilScriptLoaded(BasicJSOM.Crud.MainDemo.readListItems("pages"), "SP.js");
});
BasicJSOM.Crud.Main= function(){
function _readListItems(library){
var context = SP.ClientContext.get_current();
var targetList = context.get_web().get_lists().getByTitle(library);
var query = new SP.CamelQuery();
var listItems = targetList.getItems();
results = context.loadQuery(listItems);
context.executeQueryAsync(_onSucceed, _Fail);
function _onSucceed(){
alert("Success");
}
function _Fail(){
alert("fail");
}
}//end of read list
return {
readListItems: _readListItems
}
}
But the error am having is about the SP.js is not loaded, I am using jQuery to wait for page load, then using SP.SOD.executeOrDelayUntilScriptLoaded
. What else am I missing?