is it possible to send a value from button to Jquery AJAX with onclick function ? I have tried something like this code, but not working. There is nothing on console log.
html
<button type="button" class="hapus_krs" onclick="hapus_krs(this.value)" value="1">x</button>
<button type="button" class="hapus_krs" onclick="hapus_krs(this.value)" value="2">x</button>
<button type="button" class="hapus_krs" onclick="hapus_krs(this.value)" value="n">x</button>
script
function hapus_krs() {
var formData = {
'id_mhs': $(this).val()
};
$.ajax({
type: 'POST',
url: '<?=base_url()?>akademik/hapus_krs',
data: formData,
dataType: 'json',
encode: true
})
.done(function(data) {
console.log(data);
})
};