Add error logging, UI status indicators, and update README

This commit is contained in:
Marcus Quinn
2025-03-13 00:56:06 +00:00
parent 75b60be213
commit 3f109c22f6
4 changed files with 67 additions and 20 deletions

View File

@ -1,14 +1,21 @@
jQuery(document).ready(function($) {
$('.wpa-superstar-toggle input').on('change', function() {
var option = $(this).attr('name');
var value = $(this).is(':checked') ? 1 : 0;
var $input = $(this);
var option = $input.attr('name');
var value = $input.is(':checked') ? 1 : 0;
$.post(wpaSuperstar.ajaxurl, {
action: 'wpa_superstar_update_option',
option: option,
value: value,
nonce: wpaSuperstar.nonce
}, function(response) {
console.log(response);
if (response.success) {
$input.next('.wpa-status').remove();
$input.after('<span class="wpa-status" style="color: green; margin-left: 10px;">Saved</span>');
setTimeout(function() { $('.wpa-status').fadeOut(); }, 2000);
} else {
console.error('Error:', response);
}
});
});
});