I need to Fetch all items from a Announcement List and show each of them by using slider.For Sliding,I am using JQuery.I am facing problem in fetching all items and displaying one by one.I have used below code.
function Fetchdata() {
var ctx = new SP.ClientContext(appWebUrl);//Get the SharePoint Context object based upon the URL
var appCtxSite = new SP.AppContextSite(ctx, hostWebUrl);
var web = appCtxSite.get_web();
var list = web.get_lists().getByTitle("Announcement");
var camlQuery = new SP.CamlQuery();
//camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'Title\'/>' +
// '<Value Type=\'Text\'>Annoucement1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>');
collListItem = list.getItems(camlQuery);
ctx.load(collListItem);
ctx.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args) {
var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
listItemInfo += oListItem.get_item('Title');
listItemInfo += oListItem.get_item('Body');
}
document.getElementById('body1').innerHTML = listItemInfo.toString();
alert(listItemInfo);
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}