最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论