I am trying to debug an IE ajax issue. The data I collect in and store in an array call eachItem. It is then converted to a string using eachItem.join(''). But before it even makes it to this step I console.log the array and IE 10 and 11 return
function item() {
[native code]
}
A console.log of eachItem.length returns 1. But I can't see the contents. I later am pushing this data over ajax and getting an empty array. But I was trying to start here first to see why IE doesn't seem to read my array.
I am trying to debug an IE ajax issue. The data I collect in and store in an array call eachItem. It is then converted to a string using eachItem.join(''). But before it even makes it to this step I console.log the array and IE 10 and 11 return
function item() {
[native code]
}
A console.log of eachItem.length returns 1. But I can't see the contents. I later am pushing this data over ajax and getting an empty array. But I was trying to start here first to see why IE doesn't seem to read my array.
Share Improve this question asked Mar 16, 2016 at 20:10 CalrocksCalrocks 651 gold badge4 silver badges11 bronze badges 2-
eachItem
is not an array. Somewhere you assigned a wrong value to it. It seems you assigned a function instead of calling it. Of course without a plete example, there is nothing we can do. Please read minimal reproducible example. – Felix Kling Commented Mar 16, 2016 at 20:15 - Hmm. That would make sense. Here is a jsfiddle with the full code: jsfiddle/adibb/m0stnb7z/1 – Calrocks Commented Mar 16, 2016 at 20:24
3 Answers
Reset to default 4Internet Explorer (11) has a global function called item
which is read only. After item="foo"
, item.toString()
still shows
function item() {
[native code]
}
However it can be redeclared. After var item = foo
, item.toString()
shows
`foo`
Looking for use of item
in the fiddle code finds
item = serviceTitleRow + eachService + trip_charge;
at line 98 without previous declaration. I suggest declaring item
before use will likely fix the problem.
FWIW, Javascript strict mode treats assignment to an undeclared variable as an error and catches this error most of the time. Because function name identifiers don't have a separated name space to variable identifers, reassigning the value of a function name is allowed. However, strict mode in IE throws a different "assignment to read only property not allowed" error when trying to update the value of item
, so strict mode may have helped catch this error earlier in multiple browsers.
Review your code to find if there is any variable that has not been declared and you are using that directly. For Example:
- abc={} may cause issue in IE
- var abc={} will work
I had a variable that was not defined with the var keyword. Solved my issue.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745536931a4631948.html
评论列表(0条)