ECMA Script : To get the SharePoint 2010 list information

 

<script language="ecmascript" type="text/ecmascript">

 

    var clientContext = null;

    var oWeb = null;

    var oListColl = null;

    var oList = null;

 

    function getListInfo() {

 

        clientContext = new SP.ClientContext.get_current()

        oWeb = clientContext.get_web();

        oListColl = oWeb.get_lists();

        oList = oListColl.getByTitle('List1');

        clientContext.load(oList);

        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

    }

 

    function onQuerySucceeded() {

        var message = "List Information";

        message += "\n Title: " + oList.get_title();

        message += "\n ID: " + oList.get_id();

        message += "\n Description: " + oList.get_description();

        alert(message);

    }

 

    function onQueryFailed(sender, args) {

        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

    }

 

</script>

<input id="btnGetListInfo" onclick="getListInfo()" type="button" value="Get the List Info"/>