• Resolved Robin W

    (@robin-w)


    what on earth am I suppose to do with this error???

    It happens when I try and add a simple shortcode to gutenburg

    and then there is no way to get back to the page because the simple ‘view page’ button that we used to have has been taken away for some unknown reason.

    I used to love wordpress, now with Gutenburg, I hate it, nothing is obvious, I spend my life hovering the mouse in case something comes up that might give me a clue as to how to add/change/delete something.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Riad Benguella

    (@youknowriad)

    Hi There and sorry for the issues!

    That error can happen for several reasons and I think it’s not possible to understand the reasons without digging a bit. In general, it happens because of potential PHP errors/warnings/notices on some REST API calls.

    The errors can be generated by very different factors and you can get more details about the error from the browser’s network tab or from the error log of your server.

    If you’re unfamiliar with the developer tools and the network tab of your browser, you can check some tutorials like this https://developers.google.com/web/tools/chrome-devtools/network (for Chrome) and try to retrieve the response of the failing request.

    Now the causes can be anything and in general are unrelated to the editor directly. Conflicts with plugins can be a reason and disabling plugins one by one might help you rule out some of them.

    Also, you mention that it happens when you use a shortcode. Can you share an example of content you’re using to trigger the error?

    Thanks.

    Thread Starter Robin W

    (@robin-w)

    I tracked down the reason why – I had changed an action to a shortcode and was using ‘echo’ instead of ‘return’.

    But I would plead that the error shown (Updating failed. The response is not a valid JSON response) is less than useful.

    Presumably you know the json response sent to be able to compare it to valid responses, so why not put the error in the code so that we can get an idea as to what the cause might be.

    Gutenburg produces this error regularly (from a quick google), and no-one seems to get to the bottom of why. Most solutions seem to suggest switching back to the classic editor, which is hardly good for you.

    So could you improve the error info here to help us

    Plugin Author Riad Benguella

    (@youknowriad)

    >But I would plead that the error shown (Updating failed. The response is not a valid JSON response) is less than useful.

    I completely agree with you here, the error is not useful.

    That said, the only thing that is known to the caller at that point is that the response is not a valid JSON (expected result), so it can’t read anything from that response.

    We’re definitely open to suggestions to improve this but at the moment it’s not clear how to get more informations from the response.

    Thread Starter Robin W

    (@robin-w)

    not knowing anything about json I can’t help further, except to say that there seem to be as many reasons for the error as there are sightings of the yeti.

    Somehow you will need to improve this situation, as it seems to crop up all over the place.

    variously it is fixed by

    adding classic editor Now select the Classic Editor as the “default editor for all users” option, save your changes, and clear your website cache. Right after this, select the Block Editor as the default editor and again save the changes.

    So I’m running my dev site locally and the only way to fix it was this. Settings > Permalinks > set to custom structure and then add this /index.php/%year%/%monthnum%/%day%/%postname%/

    Do you happen to use Cloudflare by chance? If so, then most likely what’s happening here is the firewall is blocking JSON responses. When this happens, it will come back as a 5xx error. You could try temporarily disabling the firewall or the proxy altogether and see if the error goes away.

    After testing at your hosting provider (WPMU DEV), and it does look like the issue is with the firewall (WAF).Using the browser tools Network tab, I see the request is blocked and there are instructions to go to the Hosting Hub to check the WAF logs.
    Per the instructions in the log, you’ll need to whitelist your IP address or disable the rule.I whitelisted my IP address to just bypass the block and it worked.

    occurs when uploading images
    It’s pretty simple to get rid of this error and upload your images successfully.
    Select Add Image from your Gutenberg block.
    Now, instead of clicking on upload traditionally for uploading an image, Select Media Library.
    From this window, switch to the tab Upload Files – Select Files. And browse the image from your local drive.
    Surprisingly this step will let you insert the images successfully without any error.

    In my case it was due to a web server configuration (Apache2):

    AllowOverride None
    Changed it to :

    AllowOverride All
    in

    /etc/apache2/apache2.conf

    I had the same “not a valid JSON response” error when trying to publish my content. WordPress seems to do a JSON post when publishing a new post/page so I checked the network tab in my Developer Tools. If you check the “response” tab for this JSON call you might see some more details about this invalid JSON response.

    In my case (yours might be different) some deprecated debug message was outputted before the actual JSON data and messed up the response. After fixing the deprecated message publishing worked again.

    For me this error was shown in the backend editor because of a line of text in another file which echoed that line of text on each response. Incl. when WordPress internally made its own request expecting a JSON response. Once i removed that line issue disappeared.

    If you are trying this on your local or production wordpress install you may likely get this error as your .htaccess file is not writeable for security reasons.

    Error you will see in wordpress admin interface under permalink setting after you change from plain to any mode:

    If your .htaccess file was writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all.

    Make sure your .htaccess file is writeable whenever you change your permalink setting from PLAIN mode to anyother mode like POST-NAME

    I called my hosting provider (GoDaddy) and they said it was due to my Security Package not allowing my IP address to go through.

    All I had to do was add my IP address to the firewall whitelist and then I was able to edit pages again!

    and many many more

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Updating failed. The response is not a valid JSON response.’ is closed to new replies.