Skip to content
Advertisement

Mysterious Error AJAX SyntaxError: Unexpected token < in JSON at position 0

I am getting an parse error when I run the AJAX code for autocomplete. The response looks great. But I don’t why the error occurring.

Here is the Script and HTML code

JavaScript

Here is the controller with the json response

JavaScript

I tried with other functions, none of them are working. This is so mysterious, I don’t know what causes this error. Please help me on this. I almost spend the entire day for this.

Thanks in Advance

Advertisement

Answer

Finally found it. Error is causing because of user_token which is not declared in controller.

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