Support » Plugin: GDPR Cookie Compliance » Cant insert scripts, JSON error

  • Resolved steve-pheriche


    I cannot get 3rd party script to fire when the conditional is active. Troubleshooting I see that when the plugin is activated I get this JSON parse error in the logs implicating the named Moove plugin JS AJAX success action:

    jquery-migrate.min.js?ver=1.4.1:2 JQMIGRATE: Migrate is installed, version 1.4.1
    VM1534:1 Uncaught SyntaxError: Unexpected token < in JSON at position 1
        at JSON.parse (<anonymous>)
        at Object.success (main.js?ver=1.1.1:1)
        at i (jquery.js?ver=1.12.4:2)
        at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2)
        at y (jquery.js?ver=1.12.4:4)
        at XMLHttpRequest.c (jquery.js?ver=1.12.4:4)
    (anonymous) @ main.js?ver=1.1.1:1
    i @ jquery.js?ver=1.12.4:2
    fireWith @ jquery.js?ver=1.12.4:2
    y @ jquery.js?ver=1.12.4:4
    c @ jquery.js?ver=1.12.4:4
    XMLHttpRequest.send (async)
    send @ jquery.js?ver=1.12.4:4
    ajax @ jquery.js?ver=1.12.4:4
    n.(anonymous function) @ jquery.js?ver=1.12.4:4
    (anonymous) @ main.js?ver=1.1.1:1
    init @ main.js?ver=1.1.1:1
    fire @ main.js?ver=1.1.1:1
    loadEvents @ main.js?ver=1.1.1:1
    i @ jquery.js?ver=1.12.4:2
    fireWith @ jquery.js?ver=1.12.4:2
    ready @ jquery.js?ver=1.12.4:2
    K @ jquery.js?ver=1.12.4:2

    You’ll notice the at Object.success (main.js?ver=1.1.1:1) … that’s the Moove plugin. The triggering event being action:”moove_gdpr_get_scripts”,strict:e.strict,thirdparty:e.thirdparty,advanced:e.advanced} …

    Consequently any basic 3rd party script will fail to fire due to that JSON error, for example a failing script:


    fails to write to the page, and fails fire in any position, head, body, footer.

    I suspect that the JSON parse error is the cause.

    • This topic was modified 1 year, 10 months ago by steve-pheriche. Reason: splelling
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there,

    Thanks for your comments.
    Could you please provide me more details about your website? PHP version, WP version, website-url to check the issue on your front-end?


    Hi there. This site is running
    PHP Version 5.6.3, WP version 4.9.6

    the URL is currently a local dev server. I’m testing strategies for a client before committing.

    I think I have found that the issue, a clash with another plugin. Unfortunately, it is clashing with a plugin I wrote myself – a front-end registration and login plugin.

    the offending line in MY plugin (triggering the JSON error in yours) is this dashboard restriction and redirection for members. I’ll take a look at fixing my own error in this wonky looking action, but if you have any thoughts I’d welcome them.

    function pher_restrict_dashboard_to_admin() {
        if ( !current_user_can( 'manage_options' )  && $_SERVER['PHP_SELF'] != '/wp-admin/admin-ajax.php' ) {
    add_action( 'admin_init', 'pher_restrict_dashboard_to_admin', 1 );

    commenting out the //add_action in my plugin will allow your plugin to add scripts without any JSON errors

    I have resolved my issue. I amended my function to

    function pher_restrict_dashboard_to_admin() {
      if ( is_admin() && ! current_user_can( 'administrator' ) &&  !( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
        wp_redirect(home_url('/member-portal/')); exit;
    add_action( 'admin_init', 'pher_restrict_dashboard_to_admin',1);

    and everything with your plugin works fine now. Sorry for the false alarm.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cant insert scripts, JSON error’ is closed to new replies.