I have code like this (Default.aspx):
<asp:Label id="LabelA" runat="server" Text="0"></asp:Label>
<script type="text/javascript">
document.getElementById('LabelA').innerHTML = getVerificheCount('ListTitle','StatusNotOk');
</script>
Code in App.js:
var verificheList;
var ctx = SP.ClientContext.get_current();
var hostWebURL = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
var verbaleList;
var statoVerifica;
var listTitle = '';
var countItems;
function getVerificheCount(title, stato) {
statoVerifica = stato;
listTitle = title;
var hostWebContext = new SP.AppContextSite(ctx, hostWebURL);
verbaleList = hostWebContext.get_web().get_lists().getByTitle(listTitle);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(
'<View><Query><Where><Eq>' +
'<FieldRef Name=\'Verifica\'/><Value Type=\'Choice\'>' + stato + '</Value>' +
'</Eq></Where></Query></View>');
verificheList = verbaleList.getItems(camlQuery);
ctx.load(verificheList);
ctx.executeQueryAsync(function() {
countItems = verificheList.get_count();
}, onGetverificheListFail);
return countItems;
}
I'd like to use jquery promise, but where should I insert it?