0

I am using ie8 and so does everybody else. I need to make this script work for ie8. I cannot make json.parser work on IE. I tryied some of the recommendations that I saw here like json2.js modify html file etc. It does not seem to be working. Is there an alternative to this method? I really need this working and cannot figure out.

get_cpu.php outputs the data as this:

[1230000000,23]

This is my function. It works on chrome, firefox but not IE.

$(document).ready(function() {
 function request_cpu_Data() {

    $.ajax({

        url: 'get_cpu.php', 
        success: function(data) {
        alert(data.length);
                var myObj = JSON.parse(data); 
                var point = cpu_chart.series[0].points[0];
                var newVal=myObj[1];
        myDate=myObj[0];
        point.update(newVal);

        setTimeout(request_cpu_Data, 1000000); 
        },
        cache: false

    });
}
user1471980
  • 10,127
  • 48
  • 136
  • 235

1 Answers1

1

It possibly throws an exception because it cannot parse the data that your server returns.

I suspect IE8's implementation cannot parse JSON arrays.

You can try this, for example: https://github.com/douglascrockford/JSON-js/blob/master/json2.js

akonsu
  • 28,824
  • 33
  • 119
  • 194
  • so, how I should the server return the values to ie? – user1471980 Jun 13 '13 at 20:54
  • try returning `{data: [120000,4]}`. if this does not work either then return the contents of your array as an object: `{elem0: 120000, elem1: 4}`. I do not know, play with it and see what works. – akonsu Jun 13 '13 at 20:55
  • you might be able to delete JSON; then load json2.js. If JSON already exists, json2.js does nothing. if you can kill the native JSON, then it should be using the json2.js's parser instead of the faulty native one. – dandavis Jun 13 '13 at 21:18