奇怪的“空或不是对象” IE 中的错误
错误:'parent_name' 为 null 或不是对象
IE 报告:以下代码中第 3 行的
populate(default_parent, jQuery('#categoryParent').get(0), jQuery.map(categories, function (cat) {
return {
name: cat.parent_name,
value: cat.parent_slug
}
}));
:删除上面的代码块,错误就会消失,所以错误的根源肯定在这里。
类别对象就像:
var categories = [
{ parent_slug:"real_estate", parent_name:"Ακίνητα", childs: [
{child_slug: "homes", child_name: "Σπίτια"},
{child_slug: "apartments", child_name: "Διαμερίσματα"}, ]},
{ parent_slug:"jobs", parent_name:"Εργασία", childs: [
{child_slug: "restaurant_food_service_jobs", child_name: "Εστιατόρια"},
...];
在 FF、Chrome 等中一切正常。
IE reports: Error: 'parent_name' is null or not an object
for line 3 in the below code:
populate(default_parent, jQuery('#categoryParent').get(0), jQuery.map(categories, function (cat) {
return {
name: cat.parent_name,
value: cat.parent_slug
}
}));
Deleting the above chunk of code, the error goes away, so definitely the source of the error is here.
The categories object is like:
var categories = [
{ parent_slug:"real_estate", parent_name:"Ακίνητα", childs: [
{child_slug: "homes", child_name: "Σπίτια"},
{child_slug: "apartments", child_name: "Διαμερίσματα"}, ]},
{ parent_slug:"jobs", parent_name:"Εργασία", childs: [
{child_slug: "restaurant_food_service_jobs", child_name: "Εστιατόρια"},
...];
Everything works well in FF, Chrome, etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设这是完整的代码,我认为错误可能出在您用于设置类别的语法中。您有带有尾随逗号的数组和对象,例如
除 IE 之外的所有浏览器都接受此格式。删除末尾的逗号后重试。
Presuming this is the full code, I think the error is probably in the syntax you are using for setting
categories
. You have arrays and objects with trailing commas, e.g.This is accepted by all browsers except IE. Try again with the trailing commas removed.