Debugging a WordPress Ajax Error

You probably arrived here because you came across an error message in the diagnostic tool.

Ajax is required for several functions, for example the group administration page. In contrast to normal web pages, the communication via Ajax can break already when your WordPress site displays a harmless notice that would otherwise disappear in the HTML code.

Find Out The Cause

There are several things that you can try. Some of them just require you to be site administrator, for others you need access to the WordPress files:

Click “Show the Response”

If you click on the button “Show the Response” on the “Troubleshooting” screen, you may see some text that comes before the “<?xml …” part. Try to figure out, which theme or plugin has caused these messages.fix Ajax error - WordPress

Check the browser console

Open the JavaScript Console in your browser and check the error or log messages for anything that gives a hint about the cause. If you see an error mentioning XML, Ajax etc., you could try to click there to see the response that came from the server. Often it contains some lines that shouldn’t be there.

Search for the breaking point

Deactivate all other plugins and switch to a default theme. Then run the test again. If now all seems OK, re-activate them one by one (and keep running the test) to identify the one where it breaks.

Enable debugging

Add to your wp-config.php file the following lines:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );

Then run the test again and afterwards check the content of the debug.log file in the wp-content folder of your site if there is any error message that matches the time when you ran the test.

(When you’re done, don’t forget to set the true values back to false, or just delete the lines. It is also recommended to delete the file debug.log since it might reveal information about your server.)

Fix The Problem

The issue can often be solved only by the author of the plugin or theme that has caused these messages. In some cases it may, however, already help to change the PHP version on your server, to turn off WordPress debugging or to update, deactivate or replace an outdated or faulty plugin or theme.

How do you rate this article?