How to post an AJAX Request when a hidden input value change ?.
The value in hidden input is always change because of Jquery autocomplete.
I tried $("#id_pt_asal").change(function(event){
but nothing post on console log.
is there any way how to do it ?
Here the HTML
<input type="hidden" name="id_pt_asal" id="id_pt_asal" value="" />
Here the AJAX script
$(document).ready(function() {
$("#id_pt_asal").change(function(event) {
var formData = {
'id_pt_asal': $('input[name=id_pt_asal]').val()
};
$.ajax({
type: 'POST',
url: '<?=base_url()?>akademik/prodi_pindah',
data: formData,
dataType: 'json',
encode: true
})
.done(function(data) {
console.log(data);
if (data.hasil_prodi == true) {
$("#id_prodi_asal").html(data.html);
}
})
event.preventDefault();
});
});