JavaScript CookBook/AJAX Interactions/Displaying a notification while AJAX requests are being processed

From GeoMedia Smart Client
Jump to: navigation, search
GMSC 2013/2014 Javascript API Overview Form Events Types Utility Functions client-side Validation Conditions Interaction with SmartClient Cookbook Cheatsheet


Displaying a notification while AJAX requests are being processed

Problem: You want to notify the user of a pending AJAX request so that he/she doesn't navigate away from the page while the request is still being processed.

Solution: Using IG.busy you can display a page-blocking dialog while your AJAX request is pending. The busy notification is closed in the always() handler so it disappears no matter if the request was successful or not:

IG.busy({
    message: 'Loading features. Please wait...',
    title: 'Loading features'
}); //opens a notification popup
IG.getItemById('DATACONNECT').reload().always(function () {
    IG.busy.close(); //close the popup when the request completed
});


Blue.png Do not use alert() for notifications as it will block the execution of javascript as long as the dialog is open.




Other Recipes in this category: