I try to dynamically get the names of all the lists in my site using a content query web part, but apparently a CQWB can only retrieve the items in the list, but not the list name? I'm wondering how can i go this, maybe using jquery? Thank you very much for your help!!!

3 Answers 3


+1 @james

Here's the documentation to the SPServices library. http://spservices.codeplex.com/wikipage?title=Lists&referringTitle=%24%28%29.SPServices

There isn't an example on there, but I'll post one here:

        operation: "GetListCollection", 
        completefunc: function( xData, Status ) {
            console.log( Status );
            console.log( xData.responseText );

            $( xData.responseXML ).find("Lists > List").each(function() {
                var $node = $(this);

                console.log( $node.attr("Title") );

Hope this helps!


Another option is to use the JavaScript Client Object Model:


    var clientContext = new SP.ClientContext.get_current();
    var web = clientContext.get_web();
    var lists = web.get_lists();
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onListsQuerySucceeded), Function.createDelegate(this, this.onListsQueryFailed));

    function onListsQuerySucceeded() {
        var listEnumerator = lists.getEnumerator();
        while (listEnumerator.moveNext()) {
            var oList = listEnumerator.get_current();
            //Do something with oList.

    function onListsQueryFailed(sender,args) {
        alert("Failed: "+ args.get_message());      }

GetListCollection in Lists.asmx will get this for you.


Not yet sure if SPServices has implemented this, if not - give @sympmarc a shout on Twitter and suggest it to him :)

  • SPServices currently does not have a wrapper for GetListCollection according to the documentation. Aug 1, 2012 at 18:21
  • Just checked - spservices.codeplex.com/… - apparently it does? I'll let Marc add more info.
    – James Love
    Aug 1, 2012 at 18:22
  • herpaderp, there just aren't any example pages of it being used. Aug 1, 2012 at 18:24
  • 2
    GetListCollection has been there since way back in v0.2.3. Forever! Aug 1, 2012 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.