Skip to content
Advertisement

jQuery AJAX – Not receiving JSON data when on localhost using XAMPP

I’m using this code:

JavaScript

inside do_getmemes.php the post parameters are received successfully and the json is getting generated but I don’t get it on success?? Console isn’t showing anything. It works fine on the website but not when on localhost using XAMPP

It all works inside the php file, this is at the end:

JavaScript

What’s the problem here?

EDIT:

AJAX usually works, I tested by getting simple string:

JavaScript

Advertisement

Answer

The problem were irrelevant warnings which were also sent through the API back and causing parsererror SyntaxError: Unexpected token < in JSON at position 0 error.

Besides fixing them this is the way to ensure the APIs wills till work:

Disable the warnings inside the PHP file:

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