I have the following code for a checkbox
<div class="switch switch-lg switch-primary">
<input type="checkbox" name="switch" data-plugin-ios-switch checked="checked" value="usersname:1" />
</div>
When I change the checkbox, the following event is triggered
<script>
$('input[name="switch"]').on('change', function(){
$.ajax({
type: 'POST',
url: 'page.php',
data: {
example: $('#example').val()
}
}).always(function(data, textStatus, jqXHR) {
if (data.response == 'success') {
// Success
} else {
// Error
}
});
});
</script>
I am wondering how I get the value of "usersname:1" in my page.php? I'm guessing it's around example: $('#example').val()?
Basically the page.php will update a mysql database with the value 1, but specific to only that user, so i need to somehow pull up the username:1 in that script portion or the page.php but don't know how to call it.
Thanks in advance!