Error: SP context not found
Some time you will get SP context not found error, so it is always better use ExecuteOrDelayUntilScriptLoaded
Example:
$(document).ready(function(){
ExecuteOrDelayUntilScriptLoaded(startIt, "sp.js");
});
function startIt() {
var ObjContex = new SP.ClientContext.get_current();
var ObjSite = ObjContex.get_site();
var ObjWeb = ObjSite.get_rootWeb();
var ObjlstColle = ObjWeb.get_lists();
var thisList = ObjlstColle.getByTitle("MyListName");
var ObjcamlQry = new SP.CamlQuery();
ObjcamlQry.set_viewXml(......................);
var ObjItemColl = thisList.getItems(ObjcamlQry);
ObjContex.load(ObjItemColl);
}
Some time you will get SP context not found error, so it is always better use ExecuteOrDelayUntilScriptLoaded
Example:
$(document).ready(function(){
ExecuteOrDelayUntilScriptLoaded(startIt, "sp.js");
});
function startIt() {
var ObjContex = new SP.ClientContext.get_current();
var ObjSite = ObjContex.get_site();
var ObjWeb = ObjSite.get_rootWeb();
var ObjlstColle = ObjWeb.get_lists();
var thisList = ObjlstColle.getByTitle("MyListName");
var ObjcamlQry = new SP.CamlQuery();
ObjcamlQry.set_viewXml(......................);
var ObjItemColl = thisList.getItems(ObjcamlQry);
ObjContex.load(ObjItemColl);
}