Introduction
WPForms is one of the most popular WordPress form plugins, but users frequently encounter AJAX errors during form submission. These errors prevent forms from submitting properly, leaving visitors frustrated and potentially costing businesses valuable leads. The AJAX error typically appears as a spinning loader that never completes, an error message stating "An error occurred," or a form that appears to submit but never sends the notification email.
Understanding the root cause requires investigating multiple layers: the browser's JavaScript console, WordPress REST API, server configuration, and plugin conflicts. This guide provides a systematic approach to diagnose and resolve WPForms AJAX errors.
Symptoms
When WPForms encounters an AJAX error, you may observe several different symptoms:
Browser Console Errors:
``
POST https://yoursite.com/wp-json/wpforms/v1/submit 500 (Internal Server Error)
Uncaught SyntaxError: Unexpected token < in JSON at position 0
Failed to load resource: the server responded with a status of 403 (Forbidden)
User-Facing Error Messages:
``
Error: WordPress operation failed. Check wp-content/debug.log for details.
An error occurred while processing the form. Please try again.
Form submission failed. Please refresh the page and try again.
Behavioral Issues: - Form shows loading spinner indefinitely - Submit button becomes unresponsive after click - Form appears to submit but no email is received - Success message never appears - Entries not saved to WPForms database
Server-Side Errors: ```bash # Check PHP error logs tail -f /var/log/php/error.log
# Common server errors: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted PHP Warning: Cannot modify header information - headers already sent mod_security: Access denied with code 403 ```
Common Causes
- 1.REST API Blocked - Security plugins or server configuration blocking WordPress REST API endpoints
- 2.JavaScript Conflicts - Other plugins or themes loading conflicting JavaScript libraries
- 3.PHP Memory Limit - Insufficient memory allocated for form processing
- 4.ModSecurity Blocking - Web application firewall blocking form submissions
- 5.CORS Issues - Cross-origin resource sharing problems with CDN or subdomains
- 6.Plugin Conflicts - Other plugins interfering with WPForms AJAX handlers
- 7.Theme Issues - Theme JavaScript breaking WPForms functionality
- 8.Server Configuration - Nginx or Apache misconfiguration blocking POST requests
- 9.SSL/HTTPS Issues - Mixed content or certificate problems
- 10.Database Issues - Corrupted tables or connection problems
Step-by-Step Fix
Step 1: Enable Debug Mode
Before troubleshooting, enable WordPress debug mode to get detailed error information:
```bash # Edit wp-config.php vi /var/www/html/wp-config.php
# Add or modify these lines: define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ); define( 'SCRIPT_DEBUG', true );
# Check debug log tail -f /var/www/html/wp-content/debug.log ```
Step 2: Test REST API Endpoint
WPForms uses the WordPress REST API for AJAX submissions. Verify the API is accessible:
```bash # Test REST API directly curl -X GET https://yoursite.com/wp-json/
# Should return JSON response with WordPress version and routes
# Test WPForms endpoint specifically curl -X POST https://yoursite.com/wp-json/wpforms/v1/submit \ -H "Content-Type: application/json" \ -d '{"form_id": "123"}'
# Check for errors in response ```
If the REST API returns a 404 or 403 error, the issue is with server configuration or security plugins.
Step 3: Check Browser Console for JavaScript Errors
Open the browser developer tools (F12) and check the Console tab:
```javascript // Common JavaScript errors to look for:
// jQuery conflict: Uncaught TypeError: $ is not a function // Fix: Use jQuery in noConflict mode or wrap in: jQuery(document).ready(function($) { ... });
// REST API error: POST https://yoursite.com/wp-json/wpforms/v1/submit 500 // Check server error logs for details
// JSON parse error: Uncaught SyntaxError: Unexpected token < in JSON // Server returning HTML error page instead of JSON ```
Step 4: Disable Security Plugins Temporarily
Security plugins often block REST API requests:
```bash # Via WP-CLI, disable security plugins: wp plugin deactivate wordfence wp plugin deactivate sucuri-scanner wp plugin deactivate ithemes-security-pro wp plugin deactivate all-in-one-wp-security-and-firewall
# Or via FTP, rename plugins folder: mv wp-content/plugins/wordfence wp-content/plugins/wordfence-disabled
# Test form submission after each deactivation ```
If the form works after disabling a security plugin, add an exception for the WPForms REST API endpoint:
```nginx # For Wordfence, add to .htaccess or Nginx config: # Allow WPForms REST API RewriteCond %{REQUEST_URI} ^/wp-json/wpforms/ [NC] RewriteRule .* - [L]
# For ModSecurity: SecRuleRemoveById 12345 # The specific rule ID blocking requests ```
Step 5: Increase PHP Memory Limit
Insufficient memory causes AJAX failures:
```bash # Check current memory limit wp eval "echo WP_MEMORY_LIMIT;"
# Increase in wp-config.php: define( 'WP_MEMORY_LIMIT', '256M' ); define( 'WP_MAX_MEMORY_LIMIT', '512M' );
# Also check PHP configuration: php -i | grep memory_limit
# Edit php.ini if needed: vi /etc/php/8.1/fpm/php.ini memory_limit = 512M
# Restart PHP-FPM: systemctl restart php8.1-fpm ```
Step 6: Fix ModSecurity Issues
ModSecurity can block legitimate form submissions:
```bash # Check Apache error logs for ModSecurity blocks: grep -i "modsecurity" /var/log/apache2/error.log
# Check Nginx error logs: grep -i "modsecurity" /var/log/nginx/error.log
# Temporarily disable ModSecurity to test: # Apache: a2dismod security2 systemctl restart apache2
# Nginx: # Edit nginx.conf and comment out ModSecurity lines nginx -t && systemctl restart nginx
# If form works, create exception instead of disabling: # For Apache, add to .htaccess: <IfModule mod_security.c> SecRuleRemoveById 949110 942100 </IfModule>
# For specific WPForms endpoint: <LocationMatch "/wp-json/wpforms"> SecRuleEngine Off </LocationMatch> ```
Step 7: Resolve Plugin Conflicts
Identify conflicting plugins through systematic testing:
```bash # Via WP-CLI, deactivate all plugins except WPForms: wp plugin deactivate --all --exclude=wpforms
# Test form submission # If it works, reactivate plugins one by one: wp plugin activate plugin-name # Test after each activation
# Common conflicting plugins: # - Autoptimize (JavaScript optimization) # - WP Rocket (caching) # - Cloudflare (security features) # - Query Monitor (development plugin) ```
Add WPForms REST API to caching exclusions:
// Add to wp-config.php or functions.php:
// Exclude WPForms from caching
if ( ! defined( 'DONOTCACHEPAGE' ) && isset( $_SERVER['REQUEST_URI'] ) ) {
if ( strpos( $_SERVER['REQUEST_URI'], '/wp-json/wpforms/' ) !== false ) {
define( 'DONOTCACHEPAGE', true );
}
}Step 8: Check CORS and HTTPS Configuration
Mixed content or CORS issues prevent AJAX requests:
```bash # Check SSL certificate: curl -I https://yoursite.com
# Look for mixed content warnings in browser console: # Fix by updating site URLs: wp option update siteurl https://yoursite.com wp option update home https://yoursite.com
# Add CORS headers if using subdomain or CDN: # In .htaccess: <IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" Header set Access-Control-Allow-Methods "GET, POST, OPTIONS" Header set Access-Control-Allow-Headers "Content-Type, Authorization" </IfModule>
# Or in Nginx: add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization'; ```
Step 9: Check Nginx/Apache Configuration
Server misconfiguration can block POST requests:
```nginx # Nginx configuration check: # Ensure proper handling of POST requests to REST API location ~ ^/wp-json/ { try_files $uri $uri/ /index.php?$args; }
# Increase limits in Nginx: client_max_body_size 64M; client_body_buffer_size 128k;
# Check for rate limiting: # Remove or adjust limit_req zones for REST API ```
```bash # Apache configuration check: # Ensure mod_rewrite is enabled: a2enmod rewrite systemctl restart apache2
# Check .htaccess for proper WordPress rules: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress ```
Step 10: Verify Database Integrity
Corrupted database tables can cause submission failures:
```bash # Check database connection: wp db check
# Repair tables: wp db repair
# Check WPForms tables specifically: mysql -u root -p -e "CHECK TABLE wp_wpforms_entries; CHECK TABLE wp_wpforms_entry_fields;"
# If corrupted, repair: mysql -u root -p -e "REPAIR TABLE wp_wpforms_entries; REPAIR TABLE wp_wpforms_entry_fields;" ```
Verification
After applying fixes, verify the solution works:
```bash # 1. Test form submission in browser # Open form page, fill out and submit # Should show success message
# 2. Check browser console for errors # Open Developer Tools (F12) -> Console # Should show no red errors
# 3. Verify entry is saved wp wpforms entry list --form_id=123
# 4. Check email notification received # Check spam folder as well
# 5. Test REST API directly curl -X POST https://yoursite.com/wp-json/wpforms/v1/submit \ -H "Content-Type: application/json" \ -d '{"form_id": "123", "fields": {"1": {"value": "test"}}}' # Should return JSON with success message
# 6. Monitor debug log for new errors tail -f wp-content/debug.log # Submit form - should see no new errors ```
Prevention
To prevent WPForms AJAX errors from recurring:
1. Keep Everything Updated
```bash # Update WordPress core wp core update
# Update WPForms wp plugin update wpforms
# Update all plugins wp plugin update --all
# Update theme wp theme update --all ```
2. Configure Security Plugin Exceptions
```php // Add to security plugin configuration: // Whitelist WPForms REST API endpoints
// For Wordfence: add_filter('wordfence_whitelisted', function($whitelisted) { $whitelisted[] = '/wp-json/wpforms/v1/submit'; return $whitelisted; }); ```
3. Set Up Monitoring
```bash # Create a monitoring script cat << 'EOF' > /usr/local/bin/check_wpforms.sh #!/bin/bash SITE_URL="https://yoursite.com"
# Test REST API RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "$SITE_URL/wp-json/wpforms/v1/submit")
if [ "$RESPONSE" != "200" ] && [ "$RESPONSE" != "400" ]; then echo "WARNING: WPForms REST API returned $RESPONSE" # Send alert via email or Slack fi EOF
chmod +x /usr/local/bin/check_wpforms.sh
# Add to cron for hourly checks echo "0 * * * * /usr/local/bin/check_wpforms.sh" | crontab - ```
4. Regular Backup and Testing
```bash # Backup before updates wp db export wpforms-backup-$(date +%Y%m%d).sql
# Test forms after updates # Create a checklist for testing all forms ```
Related Issues
- [Fix WordPress White Screen of Death](/articles/fix-wordpress-white-screen-of-death)
- [Fix WordPress Database Connection Error](/articles/fix-wordpress-database-connection-error)
- [Fix WordPress Plugin Conflict](/articles/fix-wordpress-plugin-conflict)
- [Fix WordPress Memory Limit Exceeded](/articles/fix-wordpress-memory-limit-exceeded)
Related Articles
- [WordPress troubleshooting: Fix Child Theme Not Enqueuing Parent Styles Correc](child-theme-not-enqueuing-parent-styles-correctly)
- [Fix Database Connection Error Custom Socket Path Issue in WordPress](database-connection-error-custom-socket-path)
- [Fix Debug Log Growing Deprecated Warnings Notices Issue in WordPress](debug-log-growing-deprecated-warnings-notices)
- [Fix Fix Contact Form Not Sending On Wordpress Site Issue in WordPress](fix-contact-form-not-sending-on-wordpress-site)
- [Fix Fix Open Basedir Restriction Blocking Wordpress Issue in WordPress](fix-open-basedir-restriction-blocking-wordpress)
<script type="application/ld+json"> { "@context": "https://schema.org", "@type": "TechArticle", "headline": "WPForms AJAX Error", "description": "Troubleshoot WPForms AJAX errors. Fix JavaScript conflicts, REST API issues, server configuration, and form submission failures.", "url": "https://www.fixwikihub.com/fix-wordpress-wpforms-ajax-error", "publisher": { "@type": "Organization", "name": "FixWikiHub", "url": "https://www.fixwikihub.com" }, "author": { "@type": "Person", "name": "FixWikiHub Editorial Team" }, "datePublished": "2026-04-04T22:16:59.055Z", "dateModified": "2026-04-04T22:16:59.055Z" } </script>