hi.. I am trying to retrieve all list items from SharePoint list using JavaScript and i am getting this error:
"the file name you specified could not be used. it may be the name of an existing file or directory, or you may not have permission to access the file"
This is my code:
$(document).ready(function () {
var siteUrl = _spPageContextInfo.siteAbsoluteUrl;
retrieveListItems(siteUrl)
});
function retrieveListItems(siteUrl) {
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('Journals');
var camlQuery = new SP.CamlQuery();
this.collListItem = oList.getItems(camlQuery);
clientContext.load(this.collListItem);
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed)
);
}
function onQuerySucceeded(sender, args) {
var listItemInfo = '';
var listItemEnumerator = this.collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
listItemInfo = oListItem.get_item('Email');
}
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() +
'\n' + args.get_stackTrace());
}