有一段Json如下
在IE8中firefox12.0中结果如下(按顺序输出的,是我想要的结果)
但是到了IE9,IE10中就变成如下的结果了(明显列顺序变了,数字开头的到前面去了)
[{"SaleName_ID":"0","SaleName":"","28":"45","14":"20","13":"40","8":"50","SSD_ChargesType":"1","SSD_SaleSetType":"0"},
{"SaleName_ID":"1","SaleName":"SeleA","28":"1","14":"1","13":"1","8":"1","SSD_ChargesType":"2","SSD_SaleSetType":"1"},
{"SaleName_ID":"2","SaleName":"SeleB","28":"2","14":"2","13":"2","8":"2","SSD_ChargesType":"2","SSD_SaleSetType":"1"},
{"SaleName_ID":"3","SaleName":"SeleC","28":"3","14":"3","13":"3","8":"3","SSD_ChargesType":"2","SSD_SaleSetType":"1"},
{"SaleName_ID":"4","SaleName":"SeleD","28":"4","14":"4","13":"4","8":"4","SSD_ChargesType":"2","SSD_SaleSetType":"1"}]
因为中间的列数有可能多也有可能少,而且列名是数字,不知道列名,所以只能用for in的办法来解决
JS代码如下
var str="";
for (var Row in JsonStr) {
for (var key in JsonStr[Row])
{
str+=key + "=" + JsonStr[Row][key] + ",");
}
str+="<br>";
}
在IE8中firefox12.0中结果如下(按顺序输出的,是我想要的结果)
SaleName_ID=0,SaleName=,28=45,14=20,13=40,8=50,SSD_ChargesType=1,SSD_SaleSetType=0,
SaleName_ID=1,SaleName=SeleA,28=1,14=1,13=1,8=1,SSD_ChargesType=2,SSD_SaleSetType=1,
SaleName_ID=2,SaleName=SeleB,28=2,14=2,13=2,8=2,SSD_ChargesType=2,SSD_SaleSetType=1,
SaleName_ID=3,SaleName=SaleC,28=3,14=3,13=3,8=3,SSD_ChargesType=2,SSD_SaleSetType=1,
SaleName_ID=4,SaleName=SaleD,28=4,14=4,13=4,8=4,SSD_ChargesType=2,SSD_SaleSetType=1,
但是到了IE9,IE10中就变成如下的结果了(明显列顺序变了,数字开头的到前面去了)
8=50,13=40,14=20,28=45,SaleName_ID=0,SaleName=,SSD_ChargesType=1,SSD_SaleSetType=0,
8=1,13=1,14=1,28=1,SaleName_ID=1,SaleName=SeleA,SSD_ChargesType=2,SSD_SaleSetType=1,
8=2,13=2,14=2,28=2,SaleName_ID=2,SaleName=SeleB,SSD_ChargesType=2,SSD_SaleSetType=1,
8=3,13=3,14=3,28=3,SaleName_ID=3,SaleName=SaleC,SSD_ChargesType=2,SSD_SaleSetType=1,
8=4,13=4,14=4,28=4,SaleName_ID=4,SaleName=SeleD,SSD_ChargesType=2,SSD_SaleSetType=1,
后来在官方找到了IE兼容性的一篇文章
http://msdn.microsoft.com/en-us/library/ie/gg622937%28v=vs.85%29.aspx
提到这一点,尼玛居然不给解决办法,心中的千万匹的草尼玛在奔腾...
Firefox也是好好的。
现在只能根据浏览器来判断重新写了,有哪位知道有好办法解决的给告诉一下