Javascript 确认对话框导致IE崩溃
我有一个使用ASP.NET的web应用程序,其中C代码隐藏在jQuery11.1.2中。我有一个dropdownlist,当它被单击时,由对服务器的AJAX调用填充。web方法基于args返回要包含在下拉列表中的选项列表。有些选项返回一个附加在选项末尾的“确认”,我的成功函数从中分离出来,我在前端使用它来决定选择后该选项是否需要确认。一切都好 我的问题发生在出现确认对话框时,无论选择哪个选项,它都会崩溃IE 11。它在Chrome和Firefox中运行良好,但在IE中每次都会崩溃。我唯一的想法是IE不喜欢这一切都是在AJAX成功函数中完成的?不确定。任何想法都将不胜感激!多谢各位Javascript 确认对话框导致IE崩溃,javascript,c#,jquery,asp.net,Javascript,C#,Jquery,Asp.net,我有一个使用ASP.NET的web应用程序,其中C代码隐藏在jQuery11.1.2中。我有一个dropdownlist,当它被单击时,由对服务器的AJAX调用填充。web方法基于args返回要包含在下拉列表中的选项列表。有些选项返回一个附加在选项末尾的“确认”,我的成功函数从中分离出来,我在前端使用它来决定选择后该选项是否需要确认。一切都好 我的问题发生在出现确认对话框时,无论选择哪个选项,它都会崩溃IE 11。它在Chrome和Firefox中运行良好,但在IE中每次都会崩溃。我唯一的想法是
$('.lazy-load').click(function (e, k) {
if (e.currentTarget.length < 2) {
var callerId = getTarget(e);
callerId = callerId.id;
// parse out the true encrypted id
var encIdIndex = callerId.indexOf('ddlAction') + 9;
var encId = callerId.substring(encIdIndex);
if (encId == '' || encId == null)
return;
// get the valid workflow options for this clientice
$.ajax({
type: 'POST',
url: 'LandingSummary.aspx/GetWorkflowOptions',
async: false,
data: "{ 'csId': '{0}'}".format(encId),
success: function (data) {
ddlId = 'ddlAction' + encId;
$$(ddlId).get(0).options.length = 0; // clear
$$(ddlId).get(0).options[0] = new Option("Choose...", '');
$.each(data.d, function(index, item) {
if (item.Value.indexOf('CONFIRM') != -1) {
//strip text
var newText = item.Value.slice(0, 0 - 'CONFIRM'.length);
// add confirm attribute
var option = new Option(newText, item.Key);
option.setAttribute('data-confirm', 'confirm');
$$(ddlId).get(0).options[$$(ddlId).get(0).options.length] = option;
}
else {
$$(ddlId).get(0).options[$$(ddlId).get(0).options.length] = new Option(item.Value, item.Key);
}
});
var fullId = $$(ddlId)[0].id;
ExpandSelect(fullId);
// add warning hookup
$$(ddlId).change(function () {
var confirmAttribute = $$(ddlId).find('option:selected').attr('data-confirm');
//debugger;
if (confirmAttribute != undefined) {
var newState = $$(ddlId).find('option:selected').text();
var sure = confirm('Are you sure you want to move this authorization to the {0} state?'.format(newState));
if (!sure) {
$$(ddlId).val('');
return false;
}
}
});
},
error: function (result) {
alert('error retrieving workflow options');
}
});
}
return false;
})
function getTarget(obj) {
var targ;
var e = obj;
if (e.target != undefined) targ = e.target;
else if (e.srcElement != undefined) targ = e.srcElement;
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;
return targ;
}
});
问题签名:
问题事件名称:APPCRASH
应用程序名称:IEXPLORE.EXE
应用程序版本:11.0.9600.17631
应用程序时间戳:54b31a70
故障模块名称:MSHTML.dll
故障模块版本:11.0.9600.17631
故障模块时间戳:54b33039
异常代码:c0000005
异常偏移量:0008d910
操作系统版本:6.1.7601.2.1.0.256.48
区域设置ID:1033
附加信息1:0a9e
附加信息2:0a9e372d3b4ad19135b953a78882e789
附加信息3:0a9e
附加信息4:0a9e372d3b4ad19135b953a78882e789旁注:我确信除了将此对话框添加到选择选项之外,还必须有其他方法发送此对话框。它看起来像一个巨大的代码气味。我肯定有,但这是由某人写的大约3年前,我不试图重写这整个事情,只是想看看是否有一个简单的修复这个问题。如果不是,我的解决方案是删除确认对话框…谢谢。async:false是一种非常糟糕的做法,浏览器供应商和jQuery都不赞成这种做法。在请求完成之前,它会阻止整个页面,多年来一直不鼓励这样做。至于成功回调中的处理,这个概念是标准实践,本身不是你的问题。@charlietfl谢谢你的评论。我知道async false不是一个好的实践。这个应用程序已经开发了4年多,我是在开发顾问离开后才拿到它的。我们有一个8月4日的软发布日期,所以我的时间非常有限,希望能找到一个快速解决方案,将其提交给prod,然后解决应用程序的许多问题。再次感谢。删除该选项是值得的,可能会有所帮助