【发布时间】:2015-07-21 18:04:48
【问题描述】:
由于某种原因,我的 JSON 响应中的一个字段在 IE 中未定义。当我在 chrome 中运行它时,它看起来很好。但在 IE 中,当我写入控制台时显示未定义。
这是我的代码
function getList() {
var argument = new Object();
argument.identifier = _settings.identifier;
$.ajax({
url: "/Vendor.aspx/GetList",
data: JSON.stringify(argument),
dataType: 'json',
contentType: 'application/json',
error: function (xhr) {
console.log(xhr);
},
success: function (data) {
addData(JSON.parse(data.d));
},
type: 'POST'
});
}
function addData(data) {
if (data === undefined || data === null || data.length == 0) {
alert('No data to show');
return;
}
//this.clearRows();
for (var index = 0; index < data.length; index++) {
var d = data[index];
var row = '<tr>' +
'<td>' + d.Item + '</td>' +
'<td>' + d.AlternativeItem + '</td>' +
'<td>' + d.Condition + '</td>' +
'<td>' + d.PCS + '</td>' +
'<td>' + d.Description + '</td>' +
'<td><input type="text" class="input-field-integer" id="' + d.Item + '"/></td>' +
'<td><input type="text" class="input-field-integer" value="' + d.Price + '"/></td>' + //This field is empty in IE but not in Chrome.
'<td><input type="text" class="input-field" value="' + d.Condition2 + '"</></td>' +
'<td><input type="text" class="input-field" value="' + d.Stock + '"</></td>' +
'<td><input type="text" class="input-field" value="' + d.ETAIfNotInStock + '"</></td>' +
'</tr>';
$(this._settings.fileTable + ' tbody').append(row);
console.log(d.Price); // value is undefined???
}
}
这是 JSON 的输出: {"Item":"1234","AlternativeItem":"","Condition":"新零售","PCS":"20","Description":"我的物品详情", "Price":"100","Condition2":"new","Stock":"5 stk.","ETAIfNotInStock":"","Comment":"","RowReference":null}
【问题讨论】:
-
请包含您收到的 JSON(编辑为简短)
-
您也可以尝试清除浏览器缓存。
-
你的回复真的是双json编码的吗?
-
doule-json 编码是什么意思?
-
成功处理程序中的
data是什么样的?
标签: javascript jquery asp.net json