I have a simple HTML that
<input name="chave_binaria" type="radio" id="radio_39" value="1" class="with-gap radio-col-green" checked>
<label for="radio_39">Esquerda</label>
<input name="chave_binaria" type="radio" id="radio_40" value="2" class="with-gap radio-col-green">
<label for="radio_40">Direita</label>
And I have the following jQuery code:
$(document).ready(function(){
$(document).on('change', 'input[name="chave_binaria"]', function(){
let binary_key = $('input[name="chave_binaria"]:checked').val();
$.ajax({
url: baseURL+'requests/change_binary_key',
data: {key: binary_key},
type: 'POST',
dataType: 'json',
success: function(callback){
if(callback.status == 1){
new Noty({
type: 'success',
text: '<i class="fa fa-check"></i> Chave binária alterada com sucesso!',
timeout: 3000
}).show();
}else{
new Noty({
type: 'error',
text: '<i class="fa fa-times"></i> Erro ao alterar chave binária. Tente novamente.',
timeout: 3000
}).show();
}
},
error: function(message){
console.log('Erro ao alterar chave binária: ', message.responseText);
}
});
});
}); /* ready */
When I click the radio button to check it, the jQuery function I created does not execute. I've already tried using click in the function and also nothing. If I leave the "raw" HTML form radio button it normally functions. What can it be?