$.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
1 Answer
Reset to default 12This 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条)