0

I don’t know why but I’m not getting my list name in alert. I am using O365 and script editor web part

here is the code:

<script type=”text/javascript”>

function myGetItem(){

var siteUrl=_spPageContextInfo.siteAbsoluteUrl;

    alert(siteUrl);

var clientContext = new SP.ClientContext(siteUrl);

var oList = clientContext.get_web().get_lists().getByTitle(‘CustomListA’);

clientContext.load(oList); 

   alert(oList);//alert list name

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

}

function onQuerySucceeded() {

alert(‘success’);

alert(oList);

}

function onQueryFailed(sender, args) {

alert(‘failed’);

}

</script>

<input type=”button” id=”btnGet” onclick=”myGetItem();” value=”Get Item”/>

(Visited 17 times, 1 visits today)
Add a Comment