IE8 Json问题

发布于 2024-08-15 01:52:40 字数 790 浏览 3 评论 0原文

我面临着非常奇怪的问题,我从 django 支持的站点获取 JSON 对象并使用 eval() 执行它。它适用于除所有版本的 IE 之外的所有其他浏览器。在 IE 中,我得到“variable_name”为 null 或不是对象。我已经尽了一切努力,但到目前为止还没有运气。

这是我的 json 对象

var results = {"result":[
{
    "artist":"somevalue",
    "song":"someothervalue",
    "file":"filepathvalue",
    "views":"0",
    "songid":"1007",
    "artistimage":"default.jpg"
},

{
    "artist":"artistname",
    "song":"songname",
    "file":"anotherfilepath value",
    "views":"0",
    "songid":"1008",
    "artistimage":"default.jpg"
},
],
"prev_page": "0",
"next_page": "2"
}; 

注意:

alert(results.result[0].song)

工作正常,但

$('#somediv').html('<span>'+results.result[0].song+'</span>');

在 IE 中不起作用。有什么想法吗?

I'm facing very strange issue, I'm getting JSON object from django powered site and excuting it using eval(). It works on all the other browsers except all versions of IE. in IE, I am getting "variable_name" is null or not an object. I've tried everything I could but so far no luck.

here is my json object

var results = {"result":[
{
    "artist":"somevalue",
    "song":"someothervalue",
    "file":"filepathvalue",
    "views":"0",
    "songid":"1007",
    "artistimage":"default.jpg"
},

{
    "artist":"artistname",
    "song":"songname",
    "file":"anotherfilepath value",
    "views":"0",
    "songid":"1008",
    "artistimage":"default.jpg"
},
],
"prev_page": "0",
"next_page": "2"
}; 

Note:

alert(results.result[0].song)

work just fine, but

$('#somediv').html('<span>'+results.result[0].song+'</span>');

does not work in IE. any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

站稳脚跟 2024-08-22 01:52:40

您的结果数组末尾有一个额外的逗号。把它去掉就应该没问题了。

},],

}],

Your result array has an extra comma at the end. remove it and it should be fine.

},],

to

}],
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文