如何操作json字符串(IE和firefox浏览器兼容)
json:{seeMorePercent:"46",seeMoreWidth:"88",lookflatPercent:"0",lookflatWidth:"0",bearishPercent:"52",bearishWidth:"100"}
js:
JScript code
function Vote(i) {
jQuery.get("ashx/vote.ashx", { act: 1, item: i, randID: Math.random() }, VoteReponse, "json");
}
function VoteReponse(result) {
var item = eval(result);
document.getElementById("morepercentmap").style.width = item.seeMoreWidth*65/100;
$("#morepercent").html(item.seeMorePercent+"%");
document.getElementById("flatpercentmap").style.width = item.lookflatWidth * 65 / 100;
$("#morepercent").html(item.lookflatPercent + "%");
document.getElementById("beaspercentmap").style.width = item.bearishWidth * 65 / 100;
$("#morepercent").html(item.bearishPercent + "%");
}
firefox下无法使用
------解决方案--------------------
键和值都带上双引号。
{"seeMorePercent":"46","seeMoreWidth":"88"}
------解决方案--------------------#1楼说得有道理。
我在火狐下看了,如果是
{seeMorePercent:"46",seeMoreWidth:"88",lookflatPercent:"0",lookflatWidth:"0",bearishPercent:"52",bearishWidth:"100"} ,可以解析,
如果是
json:{seeMorePercent:"46",seeMoreWidth:"88",lookflatPercent:"0",lookflatWidth:"0",bearishPercent:"52",bearishWidth:"100"},就不行,需要在外面再加个{}
{json:{seeMorePercent:"46",seeMoreWidth:"88",lookflatPercent:"0",lookflatWidth:"0",bearishPercent:"52",bearishWidth:"100"}}这样才能解析
------解决方案--------------------
------解决方案--------------------同意一楼。。。
------解决方案--------------------