I recently stumbled upon something interesting. Here is a portion of JS code that I have:
$.ajax({
type: 'POST',
url: '/requestHandle',
data: data,
success: function(data) {
var places = JSON.parse(data);
// do something
},
error: function(data) {
// do something else
}
});
When the backend sends back data in JSON format, var places = JSON.parse(data);
works flawlessly in Chrome and Firefox by converting the JSON data into a JavaScript list. However, in Safari, this line causes an error because the data is already in JS list format. Changing it to just var places = data
resolves the issue. I'm curious as to why there's an automatic conversion taking place?
Thank you in advance.