I just added this to my page, displays a loading indicator for each ajax call (no matter where it is on the page)
/* Ajax methods */
/* show the message that data is loading on every ajax call */
var loadingMessage = 'Please wait loading data for page...';
$(function()
{
$("#AjaxStatus")
.bind("ajaxSend", function()
{
$(this).text(loadingMessage);
$(this).show();
})
.bind("ajaxComplete", function()
{
$(this).hide();
});
});
And the status:
<span id="AjaxStatus" class="ui-state-error-text"></span>
OK, based on your most recent comment, how about this option default message, or complex:
ShowStatus(true, 'Save Failed with unknown Error', 4000);
/* show message for interval */
var saveMessageText = 'Saving...';
function ShowStatus(saveMessage, message, timeInMilliseconds)
{
var errorMessage = $("#Errorstatus");
if (saveMessage)
{
errorMessage.show();
var myInterval = window.setInterval(function()
{
message = message + '...';
errorMessage.text(message);
errorMessage.show();
}, 1000);
window.setTimeout(function()
{
clearInterval(myInterval);
errorMessage.hide();
}, timeInMilliseconds);
}
else
{
errorMessage.text(message);
errorMessage.show();
window.setTimeout('$("#Errorstatus").hide()', timeInMilliseconds);
};
};
Snip from jquery ajax:
success: function(msg)
{
ShowStatus(true, 'Hey it went well', 4000);
Process(msg);
},
failure: function(msg)
{
ShowStatus(true, 'Save Failed with unknown Error', 4000);
}