Here is how to debug to make sure it is mod_security
blocking the ajax POST. You will still need to contact your host to get it fixed on shared hosting, because usually the .htaccess
way of adjusting mod_security
is disabled.
Skill level: you know how to use the Console in your web browser to see JS messages, how to edit and upload files, and preferably how to read a diff.
1. wp-config.php
: add the line define( 'SCRIPT_DEBUG', true );
2. Copy and backup wp-admin/js/theme-plugin-editor.js
and edit it as follows. This is from WordPress 5.2.2.
} );
request.fail( function( response ) {
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ // Debug mod-security or other network blockages of POST.
+ // Click + (expand) on "response" variable in browser console panel to see the server message.
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ console.log( 'xxxxx', '232.response', response );
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+
var notice = $.extend(
{
code: 'save_error',
In other words, add the console.log()
line after the request.fail()
line.
3. Upload the modded js file.
4. Go to Dashboard / Appearance / Theme Editor
, open the JS Console, and try to edit whatever was giving you trouble.
5. Contact support if the response
in the JS console says something about mod_security
.
6. Return all files to normal.
7. NOTE: don’t waste time debugging in wp-admin/admin-ajax.php
. The traffic never reaches it.