javascript - $.parseJSON not working in Internet Explorer 10 - Stack Overflow

$.parseJSON is working great in Firefox, Chrome, and Safari using the code below. However, in Internet

$.parseJSON is working great in Firefox, Chrome, and Safari using the code below. However, in Internet Explorer 10, the script fails to yield a valid object.

Here's the jsFiddle: /

And the js code:

string = '{"result":"success"}';
$('#json_string').text(string);
item = $.parseJSON(string);
$('#json_result').text(item.result);

Is there a workaround for Internet Explorer that would correct this error?

$.parseJSON is working great in Firefox, Chrome, and Safari using the code below. However, in Internet Explorer 10, the script fails to yield a valid object.

Here's the jsFiddle: http://jsfiddle/gahathat/sq6Lb/

And the js code:

string = '{"result":"success"}';
$('#json_string').text(string);
item = $.parseJSON(string);
$('#json_result').text(item.result);

Is there a workaround for Internet Explorer that would correct this error?

Share Improve this question asked Jul 20, 2013 at 20:02 amsams 1738 bronze badges 5
  • Which version of jQuery are you using? – Steven V Commented Jul 20, 2013 at 20:07
  • Did you only try it with jsFiddle? The error I get from IE9 is related to iframes. – sabof Commented Jul 20, 2013 at 20:11
  • I get the same error on my domain as well. – ams Commented Jul 20, 2013 at 20:14
  • I see the error '$' is undefined in the IE10 console when opening the fiddle. – Mooseman Commented Jul 20, 2013 at 20:16
  • And I've tried jQuery 1.9.1 and 2.0.2 – ams Commented Jul 20, 2013 at 20:16
Add a ment  | 

1 Answer 1

Reset to default 12

This should work:

$(function() {
    var string = '{"result":"success"}';

    $('#json_string').text(string);

    var item = $.parseJSON(string);
    $('#json_result').text(item.result);
});

IE has a global object called 'item' which can't be overwritten.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742343708a4426123.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信