我把它放进去,这样每次ajax调用都会显示,不管我有哪一个(我有几个)
/* show the message that data is loading on every ajax call */
var loadingMessage = 'Please wait loading data for ' + defaultPageDoctor;
$(function()
{
$("#Errorstatus")
.bind("ajaxSend", function()
{
$(this).text(loadingMessage);
$(this).show();
})
.bind("ajaxComplete", function()
{
$(this).hide();
});
});
只需创建一个带有#ErrorStatus id 的元素,例如:
<div class="newProcedureErrorStatus ajaxLoading " id="newProcedureErrorStatus">
<span id="Errorstatus" class="ui-state-error-text newProcedureErrorStatusText"></span>
<span id="Errorstatus2" class="ui-state-error-text newProcedureErrorStatusText">
</span>
</div>
现在对于奖励回合,您可以使用此区域来放置其他消息,我还包括一个计时器:
/* show message for interval */
var saveMessageText = 'Saving...';
function ShowStatus(saveMessage, message, timeInMilliseconds)
{
var errorMessage = $("#Errorstatus");
if (saveMessage)
{
errorMessage.show();
//var myNumber = 0;
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);
};
};
像这样使用它:
ShowStatus(true, 'Save Failed with unknown Error', 4000);