New 24/7 monitoring and daily cloud backups now included in every Shield Pro plan.

AJAX

Learn how to fix WordPress AJAX and admin errors.

When Save, the media library, or plugin settings spin forever, admin-ajax.php often failed in the background. This tutorial shows how to debug AJAX in browser DevTools, fix nonce and permalink issues, and isolate plugin conflicts.

Time: 20-40 minutes Level: Intermediate
Neil McNaught, founder of BugShield and WordPress author
Written by
Written by
Updated
Updated

What this problem looks like

WordPress admin relies on AJAX for autosave, media uploads, and plugin settings. A 400 response often means bad nonce or blocked request. A 500 response means a PHP fatal error in a plugin hook during the AJAX action.

Start in browser DevTools Network tab. The response body often contains -1 for failed nonce or a PHP error string when WP_DEBUG_DISPLAY is on in staging.

Step 1: Inspect admin-ajax.php in DevTools

In Chrome or Firefox, open DevTools → Network. Trigger the broken action, filter by admin-ajax.php, and click the request. Check Status, Response, and Payload tabs.

  • A 403 error: security plugin or host firewall blocking POST.
  • A 500 error: PHP fatal error in a plugin handling the action.
  • 200 with body -1: nonce or cookie/session problem.
  • 0 or failed: mixed content or wrong admin URL.

Step 2: Enable logging for AJAX fatals

Open wp-config.php in your site root, next to wp-admin and wp-content. Search for WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY first. If those lines already exist, set them to the values below instead of adding duplicates. If none of them exist, paste them above the stop editing line. Reproduce the action, then check wp-content/debug.log immediately after.

php
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'SCRIPT_DEBUG', true );

Step 3: Re-save permalinks and clear cache

Go to Settings → Permalinks in wp-admin and click Save without changes. This regenerates rewrite rules that admin-ajax.php relies on. Clear object cache, page cache, and CDN cache after URL or SSL changes.

Step 4: Test for plugin conflicts

Rename wp-content/plugins to plugins.disabled via File Manager, SFTP, or FTP. If AJAX works, rename plugins.disabled back to plugins, then activate plugins one at a time in wp-admin. Deactivate caching, security, and optimisation plugins first; they hook early into admin-ajax.php. If using Query Monitor on staging, watch ajax hooks for slow or failing callbacks.

The commands below need SSH access and will not work inside File Manager:

bash
wp plugin deactivate --all
wp plugin activate woocommerce

Step 5: Fix security and CORS blocks

If a security plugin blocks admin-ajax.php, whitelist /wp-admin/admin-ajax.php in its settings or temporarily deactivate via File Manager, SFTP, or FTP. Ensure admin loads on the same domain as siteurl, not a mismatched www variant.

When to stop DIY and hire help

AJAX failures that only happen on a live site with a full plugin stack are tedious to bisect. BugShield fixes admin-ajax.php and editor errors at a confirmed price without hourly billing surprises.

Questions answered

WordPress AJAX and admin error FAQs

Answers about admin-ajax requests, browser diagnostics, security blocks, expired sessions, and plugin conflicts in wp-admin.

What does admin-ajax response -1 mean?

WordPress rejected the request, usually failed nonce verification or expired session. Log out, clear cookies, and confirm siteurl matches how you access wp-admin.

Why did AJAX break after SSL migration?

Hardcoded http URLs and stale cookies cause nonce failures. Update URLs to https and clear all caches.

Can Cloudflare break admin-ajax?

Rocket Loader and aggressive caching on wp-admin paths can interfere. Create a page rule to bypass cache for /wp-admin/*.

How do I debug a specific plugin AJAX action?

In the Network payload, note the action parameter. Search the plugin code for wp_ajax_that_name to find the handler PHP file.

What causes WordPress AJAX and admin errors?

Common causes include a plugin conflict, expired security nonce, cached admin response, PHP fatal, blocked admin-ajax.php request, or a mismatched HTTP and HTTPS setup.

How do I inspect a failed WordPress AJAX request?

Open the browser Network panel, repeat the action, select the failed request, and record its URL, status, response body, form data, and console errors.

What does a 400 or 403 response from admin-ajax.php mean?

A 400 often means required action data is missing. A 403 commonly points to an expired nonce, permission check, security plugin, CDN, or hosting firewall.

Can logging out and back in fix a WordPress AJAX error?

Yes, when the page contains an expired nonce or session. If the error returns immediately, investigate caching, permissions, and the plugin handling the action.

How do I find which plugin broke WordPress AJAX?

Use staging to disable likely plugins, starting with the one attached to the failed action, then re-enable them individually while repeating the exact request.

When should a developer fix a WordPress AJAX error?

Get help when the request fails only for live customers, affects checkout or forms, or requires tracing custom JavaScript and PHP callbacks together.

Would you rather a developer fixed it?

Request a fix at a confirmed price and speak directly with the BugShield developer working on your site.

Request a Fix