jQuery(document).ready(function ($) {
$('#confirm-activate-mission').on('click', function () {
let missionID = $('body').attr('data-mission-id'); // We will set this in the next step
if (!missionID) {
console.error('Mission ID not found.');
return;
}
$.ajax({
url: '/wp-admin/admin-ajax.php',
type: 'POST',
data: {
action: 'activate_mission',
mission_id: missionID
},
success: function (response) {
if (response.success) {
console.log('Mission Activated:', response.data);
location.reload(); // Refresh the page to reflect the update
} else {
console.error('Activation failed:', response.data);
}
}
});
});
});