jQuery(function($){ $('#cep-run-id').on('click', function(e){ e.preventDefault(); $(this).text('Running…'); $.post(cepAjax.url, { action: 'cep_run_identifier', _ajax_nonce: cepAjax.nonce }, function(r){ alert(r.success ? r.data.tagged+' posts tagged as todo.' : 'Error – please refresh and try again.' ); location.reload(); }); }); $('#cep-queue-batch').on('click', function(e){ e.preventDefault(); // Ask user how many to queue var n = prompt('How many posts to queue? (blank = default)'); // If they click Cancel, prompt() returns null: bail out if ( n === null ) { return; } // Otherwise send—even if blank, PHP will use default $.post(cepAjax.url, { action: 'cep_queue_batch', limit: n, _ajax_nonce: cepAjax.nonce }, function(r){ alert(r.success ? r.data.queued+' posts queued.' : 'Error – please refresh and try again.' ); location.reload(); }); }); });