Reputation: 53
When I do an Ajax async call using JQuery it fails with the following message:
Syntax Error: Unexpected Token
So I capture the output and its
{"formattedBasePrice":"<span class=\\"amount\\">$30,000<\/span>","formattedTotalPrice":"<span class=\\"amount\\">$30,000<\/span>","formattedVariationTotal":"<span class=\\"amount\\">$0<\/span>"}
The funny part is that if I copy/paste that JSON from the Browser Console and try to parse it, it WORKS!
So, I change my files to UTF8 without BOM but the problem still happend.
So the next is to remove the invalid invisible characters (the only reason that make the JSON parse works if I enter the string directly)
And my question is, Anyone knows what are the most common invalid invisible characters? I already try null (\0) but nothing happend.
Thanks!
Upvotes: 0
Views: 160
Reputation: 12744
The JSON is not valid. Can you try it like this:
{"formattedBasePrice": "<span class=\"amount\">$30,000</span>", "formattedTotalPrice": "<span class=\"amount\">$30,000</span>", "formattedVariationTotal": "<span class=\"amount\">$0</span>"}
Upvotes: 1