I'm trying to use the SharePoint 2013 "Working on it..." during ajax call. This is the code:

function ShowWaitDialog() {

function BuildTable() {
    ExecuteOrDelayUntilScriptLoaded(ShowWaitDialog, "sp.js");

    //Do something


The animation loads but never closes becouse on SP.UI.ModalDialog.close() I get the error "Object doesn't support property or method 'close'".

But on https://msdn.microsoft.com/en-us/library/office/ff410259(v=office.14).aspx I see that the close method exists.

Some suggestions? Thank you


2 Answers 2


You call your method showWaitScreenWithNoClose using asyncronously with callback ExecuteOrDelayUntilScriptLoaded. If sp.js is not loaded, then closing event can fire before the wait dialog is showed.

Your code should look like this:

var waitDialog = null;

function BuildTable() {
    ExecuteOrDelayUntilScriptLoaded(function() {
        waitDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose(SP.Res.dialogLoading15);

        // DO SOMETHING;

    }, sp.js);

function myCallBack() {
    if (!fIsNullOrUndefined(waitDialog)) {
        //or SP.UI.ModalDialog.close();
  • Hello, in my situation in the DO SOMETHING part I've to call something like $.when(ajax1(), ajax2()).done(function() { CallAfterAjax(); });. In this situation where I've to call myCallBack method? Thank you
    – chenny
    Commented Sep 23, 2015 at 13:35
  • Try this `$.when(....).done(myCallBack);
    – ECM4D
    Commented Sep 23, 2015 at 14:05
  • Hello, I tried as you suggested but it didn't works. I debugged it with IE Developer Tools and Firebug putting a breakpoint inside myCallBack and it never has been called. Does it means that my Ajax call don't end?
    – chenny
    Commented Sep 23, 2015 at 14:47
  • I put function () { alert('Hello World'); } inside .done() and it shows.
    – chenny
    Commented Sep 23, 2015 at 14:50
  • Then try function () { myCallBack(); alert('Hello World'); }
    – ECM4D
    Commented Sep 23, 2015 at 18:51

You need to call close() on object returned from showWaitScreenWithNoClose(). This works for me:

var loading = SP.UI.ModalDialog.showWaitScreenWithNoClose(SP.Res.dialogLoading15);
  • Hello I already tried it, I get the same error "Object doesn't support property or method 'close'".
    – chenny
    Commented Sep 23, 2015 at 13:30

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.