After change to https ajax function don’t work right

I’m using wordress and i wrote a small script to compare posts.
After i actived ssl it brokes my script.

I got this error in the developter consol.

Uncaught SyntaxError: Unexpected token <

jQuery.ajax({
        type: "POST",
        url: "<?php echo admin_url('admin-ajax.php') ?>",
        data: {
                action: 'compare',
                post_id: $(checkbox).val(),
                _ajax_nonce: '<?php echo wp_create_nonce('compare'); ?>'
            },
        success: function(html){
                html = $.parseJSON(html);
                console.log('success');
                $('#count').fadeIn(200);
                $('#count').html(html.length);
        },
        error: function(html){
                 console.log('error');
        }
});

Related posts

1 comment

  1. Change this line:

    _ajax_nonce: '<?php echo wp_create_nonce('compare'); ?>'
    

    to this:

    _ajax_nonce: '<?php echo wp_create_nonce("compare"); ?>'
    

Comments are closed.