Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

JSOM: Retrive list items from SharePoint 2013 List

$
0
0

Dear All,

         I had written the code to retrieve the list items using JSOM ,But found no luck can any one help me the issue in below code

<script>
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', retrieveListItems);
function retrieveListItems()
{
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('CalerndarExecution');

var camlQuery = new SP.CamlQuery();
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("<View><Query><OrderBy><FieldRef Name='Function' Ascending='TRUE' /></OrderBy></Query></View>";);

this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.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 +=' <strong>Title:</strong> ' + oListItem.get_item('Function') +'<br />';
                }  $("#p").val(listItemInfo);
}


function onQueryFailed(sender, args)
{
alert('Request failed. ' + args.get_message() +'\n' + args.get_stackTrace());
}</script><p></p>




Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>