2015-07-21 156 views
0

出于某种原因,我的JSON响应中的字段在IE中未定义。当我在铬中运行它看起来很好。但在IE中,当我写入控制台时显示未定义。IE 11奇怪的JSON问题

这里是我的代码

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的输出: { “项目”: “1234”, “AlternativeItem”: “”, “条件”: “新的零售” ,“PCS”:“20”,“描述”:“我的物品细节”,“价格”:“100”,“条件2”:“新”,“库存”:“5 stk”,“ETAIfNotInStock” “,”评论“:”“,”RowReference“:null}

+0

请注明您的JSON接收响应(编辑成短) – Richard

+0

您也可以尝试清除浏览器缓存。 –

+1

是你的反应真的双json编码? – dandavis

回答

0

我清除了我的浏览器缓存,然后它开始工作。我必须清除两次,然后重新启动计算机。

IE非常特殊。

0

IE可能会缓存来自服务器的响应。

尝试加入[OutputCacheAttribute(VaryByParam = "*", Duration = 0, NoStore = true)]从服务器#WebAPI