【发布时间】:2017-09-03 03:31:12
【问题描述】:
相关(但不是重复):Is JSON.stringify() supported by IE 8?
也相关(但不同的 IE 版本):JSON object undefined in Internet Explorer 8
我正在与 QA 合作测试一项功能;该功能在我的系统上完美运行,但在他的系统上,他的开发者控制台中出现'JSON is undefined` 异常:
然而,我的身上没有任何例外。
我们俩都在 Internet Explorer 11 的兼容性视图中运行相同的代码(虽然我们使用的 IE11 版本略有不同,但他使用的是 11.0.9600.18617,而我使用的是 11.953.14393.0)。
他电脑上的“关于”对话框:
我的“关于”对话框:
下面是相关代码:
function GetNewList() {
jQuery.ajax({
url: "MyAspxPage.aspx/GetServiceInformation",
type: 'post',
// It apparently complains about this line for him
data: JSON.stringify({
"scheduleDate": jQuery('#ATextBox').val()
}),
dataType: 'json',
processData: false,
contentType: 'application/json; charset=utf-8',
// TODO: Error?
complete: function(response, status) {
if (status == 'success') {
// Presumably, this is a problem too
var jsonParsed = JSON.parse(response.responseText)
// Get my dropdown menu
var dropdown = document.getElementById('MyDropDown')
// Remove all of the existing options
var length = dropdown.options.length
for (i = 0; i < length; i++) {
dropdown.remove(0)
}
// Add all of the current objects
jsonParsed.d.each(function(element) {
var option = document.createElement('option')
option.value = element.ServiceTypeId;
option.text = element.ServiceTypeName;
dropdown.add(option)
})
// Re-add --Select--, but only if there are other options. Otherwise leave it empty.
if (jsonParsed.d.length > 0) {
var option = document.createElement('option')
option.value = 0
option.text = '--Select--'
dropdown.add(option)
dropdown.disabled = false;
} else {
dropdown.disabled = true
}
}
}
})
}
在相关说明中,我想用 UpdatePanel 完全替换它,但我was having trouble getting it working。
有谁知道这可能是什么原因造成的,我该如何解决?
【问题讨论】:
-
只是好奇所以您确实尝试过提到的解决方案?听起来您的文档模式确实已关闭,但它适用于其中一个而不适用于另一个似乎也很奇怪。我认为在 QA 的机器上升级 IE11 的版本是否可行?
-
我的猜测是网页上有标题,无法以旧的 IE 模式呈现。
标签: javascript jquery json ajax internet-explorer