Skip to content
Advertisement

Uncaught SyntaxError: Unexpected token < in JSON at position

I am currently trying to make a system of “favorites”. It works correctly but in the console of my browser gives an error (image below) and I do not understand why it happens.
I tried to find solutions but I can not understand them at all. Can anyone help me?

index.php:

JavaScript

scripts.js:

JavaScript

The error I get:

ERROR MESSAGE – IMG

Advertisement

Answer

The problem is in the excerpt res = JSON.parse (data);, the return from AJAX is HTML, but you are treating it as JSON.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement