i want to fetch the list items from office 365 developer site
by using client side object modal
pls help
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
satish babuPosted Aug 28, 2014, 3:35 AM
function getitems() {
var selectedListTitle = web.get_lists().getByTitle(listname);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("
"
"
"
listItemCollection = selectedListTitle.getItems(camlQuery);
context.load(listItemCollection, "Include(Title, ID)");
context.executeQueryAsync(onGetItemsSuccess, onGetItemsFail);
}
function onGetItemsSuccess(sender, args) {
// The list items were retrieved.
// Show all child nodes.
var listItemEnumerator = listItemCollection.getEnumerator();
var selectItemBox = document.getElementById("selectitembox");
if (selectItemBox.hasChildNodes()) {
while (selectItemBox.childNodes.length >= 1) {
selectItemBox.removeChild(selectItemBox.firstChild);
}
}
while (listItemEnumerator.moveNext()) {
var selectOption = document.createElement("option");
selectOption.value = listItemEnumerator.get_current().get_item('ID');
selectOption.innerHTML = listItemEnumerator.get_current().get_item('Title');
selectItemBox.appendChild(selectOption);
}
}
function onGetItemsFail(sender, args) {
// The list items couldn't be retrieved - display an error message.
alert('Failed to get items. Error: ' + args.get_message());
}
Manesh GolekarPosted Aug 18, 2014, 3:17 AM
http://msdn.microsoft.com/en-us/library/office/jj163201(v=office.15).aspx
It has sample example for retrieving list items using javascript client object model .
Best
M