WordPress Error- Updating failed invalid JSON response.

While saving the Post or whenever you tried to paste the AdSense ads code then your WordPress shows you the following message: “Updating failed. The response is not a valid JSON response”. This problem may persist because of many factors and I will be helping you to solve this error of Invalid Json Response.

The Invalid JSON Response error may occur in WordPress because of any of the following reasons:

  • Plugin Conflict
  • Invalid Code
  • Invalid JavaScript and HTML
  • Database Error
  • PHP version conflict
WordPress Error- Updating failed invalid JSON response
WordPress Error- Updating failed invalid JSON response

Solve AdSense Code Snippet Causing JSON error?

So whenever you tried to paste the HTML code of AdSense Ads, the following error is shown by WordPress “Updating failed invalid JSON response“. Probably you are using WordPress Block editor and experiencing the Invalid JSON error.

This problem may be solved only if you create a Shortcode for the AdSense code snippet, rather than directly pasting the AdSense codes in your Blog post.

Note– If you don’t want to write codes and play with your main website files, then you can do this by using an amazing simple plugin, Scroll down to read more.

The Invalid JSON error in WordPress occurs only if WordPress is not able to interpret the given code correctly. The Adsense code snippet for Adsense ads is a pure HTML code, but sometimes the Block Editor of WordPress does not recognize it as a pure HTML and hence causing the issue.

In order to solve the “Google AdSense code Invalid JSON error“, just follow the following steps to create a shortcode for Adsense HTML code:

  1. Use the given code to make a shortcode key for the “functions.php file of WordPress”:

function add_adsense_codes_shortcode() {
$string .= ‘your adsense code here’;
return $string;
}
add_shortcode(‘show_ad_here’, ‘add_adsense_codes_shortcode’);

  1. Just copy the Adsense code and paste that code in the place of ‘your AdSense code here’.
  2. Now open your WordPress Theme File Editor, and now select your Child theme or Parent theme, and then select “functions.php”, scroll down and select the new line and paste your created code as shown above.
  3. Now whenever you want to place your Google Adsense Ads, just paste [show_ad_here] and it will start showing ads on your posts and pages.

Note– [show_ad_here] is your shortcode as in the above-given code, you can see that we have declared the shortcode as [show_ad_here]. In fact, you can change this line and can give any shortcode name of your own choice like ‘advertisement1’, and then use the shortcode as [advertisement].

For all your Adsense codes, you have to create shortcodes in the fucntions.php file with the same code but keep in mind to change this line “adsense_codes_shortcode”, you cannot use this shortcode declaration multiple times, but have to change its name at two places in the above-given code. You may give it any name like “adsense_codes_shortcode1”.

Solve AdSense code snippet JSON error with a Plugin

  1. Open WordPress and click on “Plugins”, and then click on “Add new”.
  2. Now in the search box, search for the “Ad inserter” plugin.
  3. Install and Activate the Ad Inserter plugin.
  4. Now in Ad Inserter plugins, you will get 16 tabs to create a shortcode for 16 advertisement codes of AdSense. Just have a look at below image:
Ad Inserter Plugin to create AdSense  snippet Shortcode
Ad Inserter Plugin to create AdSense snippet Shortcode

With this amazing plugin, you can automate your AdSense ads to be automatically placed on your posts and pages, even you can use this plugin to show AdSense ads in the footer, header, comment section, and much more.

With the Ad Inserter plugin, you can decide after which paragraph and line the ads should be placed. With this plugin, you can do the Ads placement task manually, or automatically. If you want to create shortcodes with this plugin and use the shortcodes manually then you can select the manual button and it will give you the shortcodes as shown below:

Create AdSense Shortcode
Create AdSense Shortcode

How to fix WordPress Invalid JSON response?

WordPress Invalid JSON response may be triggered by any of the following reasons, so you may try the below steps which may ultimately solve the JSON error which is occurring while you are trying to save your WordPress posts.

  • Purge WordPress cache
  • Update WordPress if not updated
  • Update plugins if any of the plugins is not updated
  • Try to disable all the plugins one by one and see if the problem still persists
  • If an error occurs in the WordPress block editor then try using the Classic editor.
  • Make sure that there is no HTML or JavaScript code directly pasted into your post.
  • Try to upgrade the PHP version of your site (carefully do this otherwise it can make your site permanently down, and you may also take a backup).
  • If possible completely delete the WordPress database from Cpanel and re-install WordPress.

Also Read- Latest Posts

  • Future of Smartphones: A Look at the Google Pixel 9
    The Pixel 9 series has new premium smartphones. They feature Google’s newest technology. The range includes the Pixel 9, Pixel 9 Pro, and Pixel 9 Pro XL. Each caters to a different user base. Google Pixel 9 Series Specifications Specification Details Processor Octa-core (3.1 GHz, Single Core + 2.6 GHz, Tri-core + 1.92 GHz, Quad-core) … Read more
  • How to Downgrade from Android 15 Beta Safely
    With the Android 15 beta, you’ve leaped into the future. But are you now second-guessing yourself? You may miss the stability of Android 14, or think it’s too glitchy. Downgrading from the Android 15 beta is a viable option for anyone. This article restores a prior version with careful precision. We’ll also talk about Android … Read more
  • What is Quantum Computing and Why Does It Matter?
    Introduction Quantum computing is important for cybersecurity. In this article, you analyze the implications of quantum computing. You also cover what quantum cybersecurity means. You also cover what the future holds for data security. With technology always changing, cybersecurity is still a major worry. This problem has become more challenging with quantum computing. What is … Read more
  • 14 Modern Technologies That Will Change the World
    Our world is changing at a rate never seen before due to innovation’s quick pace. Future tech, like quantum computing and AI, could change our lives. Here, we examine 15 modern technologies that are going to transform society. Necrobotics Necrobotics is the field that studies using dead creatures to build robots. It may sound like … Read more
  • How to Start a Cybersecurity Career from Home
    Introduction The move to remote work brought many changes. One is that working from home in cybersecurity is more valuable. This post will cover how to work from home in cybersecurity. It will also cover what you should do to stay safe online. It will also cover several career paths you can choose. Can I … Read more