我有这个奇怪的问题,我会尽量详细描述。
我正在开发一个使用ASP.NET 4.0,jQuery和使用Ajax的Web模块,我有getter和setter到Web服务器。
我有一个产品选择器,在选择产品时,我将通过Ajax调用获取数据。我在细节窗格中修改产品名称,图像,描述......
它在FireFox和Chrome中运行良好,但在Internet Explorer中,产品名称(以及仅来自同一对象的产品名称 - 图像和描述)拒绝更新。
当我在Visual Studio中放置换行符并等待几秒钟并点击F5(我看到正确的产品名称)时,标签会被更改。但是当我在F5上打得非常快时,事实并非如此。所以,我放置了一个setTimeout()
代码,延迟时间为50毫秒,适用于IE。
任何人都知道为什么在Internet Explorer中出现此行为?
一些代码:
success: function (msg) {
$("#tblHardwareOptions tr").remove();
var tempDevice = JSON.parse(msg.d[3]);
$("#imgDevice").attr("src", tempDevice.image);
$("#deviceDescription").html(unescape(tempDevice.description));
//=> setTimeOut works, added the "" to be sure it is empty
// setTimeout(
// function () {
//without timeout it won't work in IE, even emptying the string
// $(lblMachineName).text("");
// $(lblMachineName).text(unescape(tempDevice.modelname));
// }
// , 50);
//Tried without jQuery, but doesn't work neither
document.getElementById(lblMachineName.replace("#", "")).innerText = unescape(tempDevice.modelname);