Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Busy Indicator does not appear before AJAX call executes

Hello,

I’m trying to display a BusyIndicator on my screen after a button click event, and hide it when execution of the corresponding call returns.  If I put a breakpoint in my code before the AJAX call fires, the busy indicator appears, but if I do not have a breakpoint and click the button, the busy screen never pops up, even though execution of the call takes 20-25 seconds.  What can I change to make sure the busy indicator comes up every time?

executeCall = function (oData, viewPrefix) {

        var message = [];

        var success = false;

     

       sap.ui.core.BusyIndicator.show(0);

        $.ajax({

            type: 'POST',

            url: pps.config.pmvSvcUri,

            data: JSON.stringify(oData),

            contentType: 'application/json',

            async: false

        }).done(function (results) {

            if (results.errors.length > 0) {

                utilities.displayError(results.errors[0]);

            }

            else if (results.messages.length > 0) {

                 results.messages.forEach(function (msg) {

                      message.push(

                      + "EVENT_DATE: " + msg.EVENT_DATE + "; \n"

                      + "USERID: " + msg.USERID + "; \n"

                      + "FUNCTION_NAME: " + msg.FUNCTION_NAME + ";\n"

                      + "ERROR_MSG: " + msg.ERROR_MSG + "; \n"

                      + "ERROR_CODE: " + msg.ERROR_CODE + "; \n"

                      + " - " + msg.ERROR_DTL

                      + "\n");

                });

               utilities.displayError(message[0], results.messages[0].ERROR_MSG);

                sap.ui.core.BusyIndicator.hide();

            }

       else {

       success = true;

       if (results.insertedPmtId){

            oData[0].ID = results.insertedPmtId;

       }

       sap.ui.core.BusyIndicator.hide();

       }

        }).fail(function (results) {

            if (results.error.length > 0) {

                 utilities.displayError("Error: " + results.error, 'Error');

            }

            else {

                 utilities.displayError("Error: " + results.status + ' ' + results.statusText, 'Error');

            }

            sap.ui.core.BusyIndicator.hide();

        });

        return success;

    },

Former Member
Former Member replied

hi Andy

If the ajax call is synchronous, then the browser to block until the response returns, hence there are no chance for the indicator to appear.

thanks

-D

2 View this answer in context
Not what you were looking for? View more on this topic or Ask a question