Strange "Null or not an object" error in IE
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.
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.
var myArray = ['item1', 'item2',];
var myObject = {foo: 'item1', bar: 'item2',}
This is accepted by all browsers except IE. Try again with the trailing commas removed.
精彩评论