I have an interval check thats returning and unexpected token error. I'm doing a call to admin-ajax.php every second and I'm expecting to get an integer value + 1 on each check. I've checked the output of the session variable that I'm using to transfer across from another function and that works fine. I know I'm close to nailing this - just failing at the last hurdle. Any help would be great.
Jquery post call function is:
var cjd_interval = null;
function cjd_interval_checker(){
var cjd_email_fans_nonce = $("#cjd_email_nonce").val();
var data = {
'action': 'cjd_update_progress_bar',
nonce: 'cjd_email_nonce'
};
$.post(cjdAjax.ajaxurl, data, function(response) {
var result = jQuery.parseJSON(response);
console.log(result);
$("#cjd-progressbar").attr('value', result);
});
};
And the PHP function is:
function cjd_update_progress_bar() {
/**
* Check Permissions
*/
if( current_user_can( 'manage_options' ) ) {
$count = $_SESSION['counter'];
echo json_encode( $count );
}
wp_die();
}
add_action( 'wp_ajax_nopriv_cjd_update_progress_bar', 'cjd_update_progress_bar' );
add_action( 'wp_ajax_cjd_update_progress_bar', 'cjd_update_progress_bar' );