之后是写script了
<script type="text/javascript"> var numberOfEmails_original= 0; var app = Sys.Application; app.add_init(applicationInitHandler); function applicationInitHandler(sender, args) { InboxService.GetLatestNumberOfEmails(OnCurrentNumberOfEmailsReady);
|
首先,默认的当然是0封邮件了,有变量来存放当前邮件数量,之后是在ajax中的初始化事件中调用webserice的方法了,并且回调OnCurrentNumberOfEmailsReady方法,
function OnCurrentNumberOfEmailsReady(result, userContext, methodName) { numberOfEmails_original= result; // Start Checking StartChecking(); } |
OnCurrentNumberOfEmailsReady方法将WEBSERVICE调用的结果(当前状态下有多少封信RESULT)返回给变量,然后调用sartchecking()方法
function StartChecking() {
InboxService.GetLatestNumberOfEmails(OnLastestNumberOfEmailsReady);
}
startchecking方法,继续回调OnLastestNumberOfEmailsReady方法
function OnLastestNumberOfEmailsReady(result, userContext, methodName) { var numberOfEmails_new= result; if (numberOfEmails_new > numberOfEmails_original) { ShowPopup(); $get("modalBody").innerHTML= numberOfEmails_new - numberOfEmails_original; // Update the count here numberOfEmails_original= numberOfEmails_new; |
这个方法,用当前邮件数-原来邮件数,就得出新增了多少封邮件了,再将结果赋值给显示区域的modalbody,并且记得把当前邮件数量的,变量更新哦(numberOfEmails_original= numberOfEmails_new;)
然后再用setimeout来设置每隔10000毫秒检查一次了
function ShowPopup() { $get("UpdateProgress1").style.visibility= "visible"; $get("UpdateProgress1").style.display= "block"; } function HidePopup() { $get("UpdateProgress1").style.visibility= "hidden";
|
文章来源于领测软件测试网 https://www.ltesting.net/