While attempting to retrieve a JSON file from a server, I encountered an issue. The JSON file contains the following data:
var reviews = [
{
"firstName":"Simon",
"lastName":"Lock",
"fullName":"Simon Lock",
"location":"San Francisco",
"reviewTitle":"Super quality.. I will show here again!",
"reviewBody":"Super nice quality, fast devilery, good prices. I will shop here again!",
"starRating":"5"
},
{
"firstName":"John",
"lastName":"Smith",
"fullName":"John Smith",
"location":"New York",
"reviewTitle":"Princely Sum",
"reviewBody":"A decent local curry house in Faversham, Kent known for its Elvis nights.",
"starRating":"4"
},
];
As anticipated, an error occurred while retrieving the file using $.ajax
:
SyntaxError: Unexpected token v
Since it is not in valid JSON format, I attempted to use a different dataType
.
My inquiry is:
Is there a method to store that variable from the JSON file in another variable for normal manipulation?
I also tried utilizing FileReader()
, but unfortunately it did not work for me.
Thank you