0

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.

Calrocks
  • 65
  • 1
  • 4
  • 11
  • `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 complete example, there is nothing we can do. Please read [mcve]. – Felix Kling Mar 16 '16 at 20:15
  • Hmm. That would make sense. Here is a jsfiddle with the full code: https://jsfiddle.net/adibb/m0stnb7z/1/ – Calrocks Mar 16 '16 at 20:24

3 Answers3

4

Internet 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.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
traktor
  • 17,588
  • 4
  • 32
  • 53
1

Review your code to find if there is any variable that has not been declared and you are using that directly. For Example:

  1. abc={} may cause issue in IE
  2. var abc={} will work
Ruchi
  • 11
  • 2
0

I had a variable that was not defined with the var keyword. Solved my issue.

Calrocks
  • 65
  • 1
  • 4
  • 11