I had written the below code to get the information of SharePoint list , And also I had used SP.UI.ModalDialog . Unfortunately the dialog box is not getting closed.
Can any one please help me what's wrong in my below code
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
alert('start script');
ExecuteOrDelayUntilScriptLoaded(myfunction1, "sp.js");
function myfunction1() {
var dialog = SP.UI.ModalDialog.showWaitScreenWithNoClose('Processing...', 'Request is in progress...', 80, 300);
retrieveListItems().done(function (data) {
dialog.close(0);
dialog = null;
//processing your data
alert("Data Loaded");
});
}
function retrieveListItems()
{
alert('enters function');
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('orderetails');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("<View><Query><OrderBy><FieldRef Name='Title' Ascending='TRUE' /></OrderBy></Query><RowLimit>10</RowLimit></View>");
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync( Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed) );
}
function onQuerySucceeded(sender, args)
{
var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
//alert('title ' + oListItem.get_item('Title'));
listItemInfo +=' <strong>Table top Sessions:</strong> ' + oListItem.get_item('Title') +' <br />';
// alert("Lookup Value is" + +columnFieldValue);
}
$('#divHelloWorld').html(listItemInfo );
}
function onQueryFailed(sender, args)
{
alert('Request failed. ' + args.get_message() +'\n' + args.get_stackTrace());
}
</script>
<p id="divHelloWorld">Hello World!</p>