I'm trying to pass multiple checkbox values to the DB using the settings API and AJAX. My setup works with PHP but something is wrong with my JS.
Here is my HTML form; basically 4 checkboxes
<input name="wpbackitup[wp_backitup_settings_db]" id="wp-backitup-settings-db" type="checkbox" value="1" <?php checked('1', $options['wp_backitup_settings_db']); ?> />
<input name="wpbackitup[wp_backitup_settings_plugins]" id="wp-backitup-settings-plugins" type="checkbox" value="1" <?php checked('1', $options['wp_backitup_settings_plugins']); ?> />
<input name="wpbackitup[wp_backitup_settings_themes]" id="wp-backitup-settings-themes" type="checkbox" value="1" <?php checked('1', $options['wp_backitup_settings_themes']); ?> />
<input name="wpbackitup[wp_backitup_settings_uploads]" id="wp-backitup-settings-uploads" type="checkbox" value="1" <?php checked('1', $options['wp_backitup_settings_uploads']); ?> />
and my JS:
`$("#wp-backitup-options input").change( function() {
$.post( 'options.php', {
'wpbackitup[wp_backitup_settings_db]' : $('#wp-backitup-settings-db').val(),
'wpbackitup[wp_backitup_settings_plugins]' : $('#wp-backitup-settings-plugins').val(),
'wpbackitup[wp_backitup_settings_themes]' : $('#wp-backitup-settings-themes').val(),
'wpbackitup[wp_backitup_settings_uploads]' : $('#wp-backitup-settings-uploads').val(),
} ).error( function() {
$("#wp-backitup-settings-status").html('Updated');
}).success( function() {
$("#wp-backitup-settings-status").html('Error');
});
return false;
});`
As it stands, it displays error and does not update the DB