Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
JavaScript
<script type="text/javascript">
window.onload = function(){ ExecuteOrDelayUntilScriptLoaded(ViewItem, 'sp.js'); };
function ViewItem()
{

var ctx = new SP.ClientContext.get_current();
 this.ListColl = ctx.get_web().get_lists();
 ctx.load(this.ListColl);
ctx.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFail));
}

function onSuccess(sender, args)
{
    var listEnum = this.ListColl.getEnumerator();
    while(listEnum.moveNext())
    {
        var oList = listEnum.get_current();
        document.getElementById('resultpanel').innerHTML=oList.get_title();
    }
}

function onFail(sender, args)
{
    alert('FAIL!');
}
</script>
Posted
Updated 7-Jul-15 12:13pm
v2

1 solution

JavaScript
function demo()
{
    var clientContext = new SP.ClientContext.get_current();
    var web = clientContext.get_web();
    this.lists = web.get_lists();
    clientContext.load(lists);

    clientContext.executeQueryAsync(Function.createDelegate(this, this.onListItemsLoadSuccess), Function.createDelegate(this, this.onQueryFailed));
}

function onListItemsLoadSuccess(sender, args) {

    var count = this.lists.get_count();

    for (x = 0; x < count; x++)
    {
        if(this.lists.itemAt(x).get_baseType() === 1) {
            var listTitle = this.lists.itemAt(x).get_title();
            console.log(listTitle);
        }
    }
}

function onQueryFailed(sender, args) {
    alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900