JavaScript AJAX / JSON Issue with WPP v5.2.0
-
Hello,
with WPP v5.2.0 and my WordPress Installation (newest Version) and JQuery 3.4.1, an JavaScript Error is thrown for the AJAX Request, that is generated within your Front.php Code:
wp_register_script(‘wpp-js’, plugin_dir_url(dirname(dirname(__FILE__))) . ‘assets/js/wpp-5.2.0.min.js’, [], WPP_VERSION, false);
$params = [
‘sampling_active’ => (int) $this->config[‘tools’][‘sampling’][‘active’],
‘sampling_rate’ => $this->config[‘tools’][‘sampling’][‘rate’],
‘ajax_url’ => esc_url_raw(rest_url(‘wordpress-popular-posts/v1/popular-posts’)),
‘ID’ => $is_single,
‘token’ => wp_create_nonce(‘wp_rest’),
‘lang’ => function_exists(‘PLL’) ? $this->translate->get_current_language() : null,
‘debug’ => WP_DEBUG
];
wp_enqueue_script(‘wpp-js’);
wp_add_inline_script(‘wpp-js’, json_encode($params), ‘before’);The JS Error is thrown for the inproper JSON Format for “:”. But the original problem of this seems to be lying within the AJAX handling code, not the JSON block. I’ve already tried to fix that issue by adding surrounding ” (brackets) to each JSON value, but this seems not to be the source of the problem.
I tried to update my JQuery version to newest 3.5.1 and also to migrate it down to 3.0 or 1.9, without any positive result. I’m sure that your Plugin is working with WordPress Standard JQuery version, but did you tried it with a newer version?
Thanks for your Plugin, hope that you could help to fix it.
Best regards,
Carsten
- The topic ‘JavaScript AJAX / JSON Issue with WPP v5.2.0’ is closed to new replies.