$ .parseJSON does not work in Internet Explorer 10

$. parseJSON works fine in Firefox, Chrome, and Safari using the code below. However, in Internet Explorer 10, the script cannot get a valid object.

Here's jsFiddle: http://jsfiddle.net/gahathat/sq6Lb/

And 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 fix this error?

+4
source share
1 answer

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" that cannot be overwritten.

+12
source

Source: https://habr.com/ru/post/1492505/


All Articles