• Hello. When I try to paste HTML code into the block editor, my post is not able to be saved or updated and generates this error code “Updating failed. The response is not a valid JSON response.” I’ve been advised that this is a block editor problem and I should switch to the classic editor, but I much prefer using the block editor and would like to resolve this compatibility issue between the HTML code and the block editor. Thank you.

Viewing 15 replies - 1 through 15 (of 30 total)
  • What kind of tags do you have in HTML?

    How are you adding the code? The Gutenberg blocks are react components. They are transformed into HTML with comments to be stored in the database. If you are switching to the code editor and just pasting it in. You will probably encounter some problems. There is an HTML block use it if you are not already doing so.

    • This reply was modified 2 years, 6 months ago by mrtom414.
    Thread Starter heyyoufinance

    (@heyyoufinance)

    I choose the block “Custom HTML” and I paste the HTML code there. I discovered the issue when I tried to paste HTML code to display Google ads on my post. I’ve done it this way for months and months and this is the first time running into an issue.

    Do you have a concrete example of the problematic HTML code at hand?

    Which WordPress version do you use exactly? Do you have the Gutenberg plugin additionally installed and if so in which version?

    Thread Starter heyyoufinance

    (@heyyoufinance)

    Here is an example HTML code that I’ve tried to publish: `<script async src=”https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5069043027173587&#8243;
    crossorigin=”anonymous”></script>
    <!– Ad Unit 1 Square –>
    <ins class=”adsbygoogle”
    style=”display:block”
    data-ad-client=”ca-pub-5069043027173587″
    data-ad-slot=”1542860076″
    data-ad-format=”auto”
    data-full-width-responsive=”true”></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>`

    I use WordPress version 5.9.2

    I do not have the Gutenberg plugin additionally installed.

    I can insert the code without any problems in a wordpress 5.9.2 installation without any plugins.

    Try it and see if it works for you without any active plugins. If so, one of the plugins used is responsible. Possibly also the theme (I have TwentyTwentyTwo active), but imho rather unlikely.

    Thread Starter heyyoufinance

    (@heyyoufinance)

    Even if I deactivate all of my plugins, I still get the same error message. I use the theme Generate Press.

    Even with Generate Press, I can’t reproduce the error when updating the page in Gutenberg. However, I noticed something else. When saving and reopening the page, the HTML block cannot be displayed because it contains “invalid code”. The reason is the HTML comment in the code. So:

    <!- Ad Unit 1 Square ->

    Remove this one line from your code.

    If this does not solve the problem, you should check the hosting to see if there is any log entry for the memory problem. Your hoster can tell you where to find the log files. If necessary, debugging with WordPress would also be useful, it creates its own log file. See: https://www.ads-software.com/support/article/debugging-in-wordpress/

    Thread Starter heyyoufinance

    (@heyyoufinance)

    I removed that line from the code & still received the same error message.

    I then reached out to my host & was advised that there was no error recorded in the log. I’m at a dead end.

    Thread Starter heyyoufinance

    (@heyyoufinance)

    Host claims that it’s an issue with the block editor.

    You are adding javascript not html. You should either use an adsence plugin from the plugin directory or enqueue the script in the functions.php.

    Thread Starter heyyoufinance

    (@heyyoufinance)

    No, I am adding HTML. I have inserted ads this way for over 50 posts and it has not been an issue until now.

    Just to be sure: you use the HTML block in the Gutenberg editor for this? Does the page in question have any other content? Have you ever inserted this code alone in a page without any other content?

    If you can’t find a solution here, you should get someone to look at it directly. That would be possible e.g. here: https://jobs.wordpress.net

    EDIT:
    One more thought: you could also check your browser’s developer console to see what exactly is logged there when you save. How to get there is described here: https://www.ads-software.com/support/article/using-your-browser-to-diagnose-javascript-errors/

    • This reply was modified 2 years, 6 months ago by threadi.

    Open the inspector go to console look to see if there is any JavaScript errors. You are running a script so if there is a problem it should show up under the console. The script tag is used to run scripts. The html part of the code is the target area for the script.

    If there is an error it should appear under the console area of the inspector. Without seeing the site or error messages it not really possible to tell what going on.

    Thread Starter heyyoufinance

    (@heyyoufinance)

    Here is my error message when looking at Console

    Uncaught
    T
    message: "adsbygoogle.push() error: All ins elements in the DOM with class=adsbygoogle already have ads in them."
    name: "TagError"
    pbr: true
    stack: "TagError: adsbygoogle.push() error: All ins elements in the DOM with class=adsbygoogle already have ads in them.\n    at np (https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5069043027173587:235:210)\n    at cp (https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5069043027173587:231:340)\n    at https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5069043027173587:226:47\n    at di.n.oa (https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5069043027173587:85:794)\n    at Vi (https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5069043027173587:100:1098)\n    at Zo (https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5069043027173587:226:29)\n    at Yo (https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5069043027173587:223:69)\n    at https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5069043027173587:243:475\n    at di.n.oa (https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5069043027173587:85:794)\n    at Vi (https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5069043027173587:100:1098)"
    <a href="https://codex.www.ads-software.com/Prototype">Prototype</a>: Error
    constructor: ? T(a)
    <a href="https://codex.www.ads-software.com/Prototype">Prototype</a>: Object
Viewing 15 replies - 1 through 15 (of 30 total)
  • The topic ‘HTML code posting error in Block Editor’ is closed to new replies.