我正在将鼠标悬停在图像滑块上调用页面方法以显示数据库中的图像。问题是我收到了多个回调。有谁知道如何解决这个问题?
我用于页面方法的代码:
var contextArray = "img";
pageMethodConcept = {
callServerSideMethod: function (id) {
PageMethods.GetItemLargeImage(id, pageMethodConcept.callback, pageMethodConcept.Failcallback, contextArray);
}, callback: function (result, userContext, imagePreview) {
//alert(result);
if (userContext = "img") {
//replace img source with result
document.getElementById("displayPreviewImage").src = result;
return false;
}
}, Failcallback: function (result, userContext) {
alert("failed");
}
}
设置定时器的代码:
var alertTimer = 0;
if (alertTimer == 100) {
alert("time 100");
alertTimer = setTimeout(pageMethodConcept.callServerSideMethod(this.id), 0);
}
else {
alertTimer = setTimeout(pageMethodConcept.callServerSideMethod(this.id), 100);
alert("time ");
}