18

I am trying to write some codes to get json file and read. But this codes works in chrome, doesn't works in IE11 and I need to use IE, What is the real solution for solve this problem actually. I changed some value names but same problem still seems.

Error Message

<html xmlns="http://www.w3.org/1999/xhtml">
    <head> 
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    </head>
    <body>   
     <table id="userdata" border="0.02">
      
       <th>Revision  Date</th>
       <th>Document  Name</th>
       <th>Department </th>
       <th>Description</th>
       <th>Link</th>
     </table>
    <script>
              myObjects = [];
            $.getJSON('https://api.myjson.com/bins/1djve3', function(deneme) {
            myObjects = Object.values(deneme);
            console.log("Objects in array " + myObjects.length);
            
             $.each(myObjects, function(i, person) {
                  $('#userdata  th:nth-child(2)').html(person.revisiondate)
                  console.log("Person-" + person.revisiondate);
                  console.log("Person-" + person.documentname);
                  console.log("Person-" + person.department);
                  console.log("Person-" + person.description);
                  console.log("Person-" + person.link.split('href=')[1]+"' "+person.link.split('href=')[1]);    
                  
                  var $row = 
           "<tr><td>" + person.revisiondate + 
                                "</td><td>" + person.documentname + 
                                "</td><td>" + person.department +
                                "</td><td>" + person.description + 
                                "</td><td><a target='_blank' href='"+ person.link.split('href=')[1]+"' >"+person.link.split('href=')[1]+"</a></td></tr>"  
    
    $('table> tbody:last').append($row);
                }); 
              }); 
        
           
    </script>
    </body>
    </html> 
prasanth
  • 19,775
  • 3
  • 25
  • 48
MCoskun60
  • 183
  • 1
  • 1
  • 6
  • 1
    and if you expect people to spend their precious time to help you answer your questions, then in return you should also extend general appreciation by accepting their answers in case that works. Otherwise no one will be interested in helping you. – mp77 Apr 07 '17 at 09:18

1 Answers1

42

Instead of this line,

myObjects = Object.values(deneme);

write,

myObjects = Object.keys(deneme).map(itm => deneme[itm]);

Because, Object.values is an experimental feature and it is not being supported in IE.

If your browser doesn't supports arrow functions too then write,

myObjects = Object.keys(deneme).map(function(itm) { return deneme[itm]; });
Rajaprabhu Aravindasamy
  • 63,064
  • 13
  • 90
  • 119