dnsServerapiREST APIhourglass_bottomloading-issueinfoajaxcodejsoncodeJavaScriptlabelCommonwarningModerate

Unexpected token ‘<' in JSON at position 0

The browser tries to parse a response as JSON but receives HTML. The first character of an HTML document is ‘<', which triggers the syntax error. This situation appears when an AJAX endpoint returns an error page, a login screen, or any markup instead of a JSON payload.

WordPress generates JSON through admin‑ajax.php, the REST API, and Gutenberg requests. Any PHP fatal error, warning, or stray output that appears before wp_send_json() corrupts the response. Authentication failures also redirect to wp‑login.php, producing HTML.

Server‑level redirects, ModSecurity blocks, or mis‑configured rewrite rules may serve static HTML files for the requested URL. Security plugins often intervene and replace the JSON with a 403 page.

When the response body starts with ‘<', JSON.parse throws the error and the JavaScript code stops. The UI freezes, blocks fail to load, and saving actions never complete.

Identifying the exact source of the HTML output is essential. The error does not indicate a problem with the JSON parser itself; it signals that the endpoint delivered the wrong content type.

Symptoms

[dashicons-warning]
Console error
SyntaxError appears in the JavaScript console
[dashicons-admin-generic]
Admin UI freeze
Gutenberg blocks, media library, or settings panels stop responding
[dashicons-media-code]
Network response shows HTML
DevTools network tab displays a full HTML page instead of JSON

Common Causes

HTML response from endpoint
AJAX URL points to a static page or error template
PHP fatal error before JSON output
Undefined function or memory exhaustion prints a warning
Authentication redirect
Missing or expired nonce sends user to wp‑login.php
Server redirect or rewrite
HTTPS to HTTP or www to non‑www redirect returns HTML
Security plugin block
ModSecurity or firewall serves a 403 HTML page
Need this fixed right now?

Don't waste your day debugging. Our experts can Fix your issues in under 2 hours.*

Success Rate

100% Guaranteed

Starting from

$35 /hour
99+

Trusted by Business Owners

“I spent 3 days trying to fix the Elementor loading loop. These guys fixed it in 20 minutes. Lifesavers!”

— Sarah J., Web Designer

Related Issues

contact_mail
Contact Form 7: REST API request failed: 503 Service Unavailable
A 503 Service Unavailable response stops Contact Form 7 from sending data...
apiREST APIerror503descriptioncontact-form-7
contact_mail
Contact Form 7: REST API request failed: 429 Too Many Requests

The form tries to send data through the WordPress REST API. The...

apiREST APIerrorerrorsecurityfirewalldescriptioncontact-form-7settingsserver_configuration
contact_mail
Contact Form 7: REST API request failed: 401 Unauthorized

The form tries to send data via the WordPress REST API. The...

apiREST APIadmin_panel_settingspermissionsdescriptioncontact-form-7lock401
contact_mail
Contact Form 7: File upload error: temporary directory missing

The error appears when Contact Form 7 cannot locate a writable temporary...

codePHPcloud_offupload erroradmin_panel_settingspermissionsdescriptiontemporary filedescriptioncontact-form-7
contact_mail
Contact Form 7: Mail (2) sending failed: PHP mail() function disabled

Contact Form 7 reports a failure for Mail (2) when the PHP...

codePHPerrorerrordescriptioncontact-form-7mailMailsettingsserver_configuration
contact_mail
Contact Form 7: Mail (2) sending failed: SSL certificate verification failed

Contact Form 7 reports a failure when trying to send the secondary...

errorerrorlocksslcodecURLdescriptioncontact-form-7