Get List Items Using JSOM
var Title = "Document Sharing";
var CurrentFolderItems;
function GetListItems() {
var clientContext = new SP.ClientContext.get_current();
var oWeb = clientContext.get_web();
var currentTabList = this.oWeb.get_lists().getByTitle("Budgets");
var query = new SP.CamlQuery();
var querytext = '<View><Query><Where><Neq><FieldRef Name="Title" /><Value Type="Text">0</Value></Neq></Where></Query></View>';
query.set_viewXml(querytext);
CurrentFolderItems = currentTabList.getItems(query);
clientContext.load(CurrentFolderItems);
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQueryGetFolderItemsSucceded),
Function.createDelegate(this, this.onQueryGetFolderItemsFailed));
}
function onQueryGetFolderItemsSucceded() {
console.log("1");
var data="";
var ListEnumerator = this.CurrentFolderItems.getEnumerator();
while(ListEnumerator.moveNext()){
var item = ListEnumerator.get_current();
var image = item.get_item("Title");
var itemimg = item.get_path("Image");
for(i in itemimg )
{
console.log(itemimg[i]);// data += item[i];
}
data += "\n"+image+ itemimg;
}
alert(data);
}
function onQueryGetFolderItemsFailed(sender,args){
console.log(args.get_message());
}
GetListItems();
var Title = "Document Sharing";
var CurrentFolderItems;
function GetListItems() {
var clientContext = new SP.ClientContext.get_current();
var oWeb = clientContext.get_web();
var currentTabList = this.oWeb.get_lists().getByTitle("Budgets");
var query = new SP.CamlQuery();
var querytext = '<View><Query><Where><Neq><FieldRef Name="Title" /><Value Type="Text">0</Value></Neq></Where></Query></View>';
query.set_viewXml(querytext);
CurrentFolderItems = currentTabList.getItems(query);
clientContext.load(CurrentFolderItems);
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQueryGetFolderItemsSucceded),
Function.createDelegate(this, this.onQueryGetFolderItemsFailed));
}
function onQueryGetFolderItemsSucceded() {
console.log("1");
var data="";
var ListEnumerator = this.CurrentFolderItems.getEnumerator();
while(ListEnumerator.moveNext()){
var item = ListEnumerator.get_current();
var image = item.get_item("Title");
var itemimg = item.get_path("Image");
for(i in itemimg )
{
console.log(itemimg[i]);// data += item[i];
}
data += "\n"+image+ itemimg;
}
alert(data);
}
function onQueryGetFolderItemsFailed(sender,args){
console.log(args.get_message());
}
GetListItems();