0
觸發,只要我輸入我的家庭ID即可。它會加載記錄和輸入ID chli_hh_id也將被填充。並且如果輸入#cli_hh_id已填充。在href =」不被觸發。好心幫請..謝謝:)關於更改事件不會通過ajax php
這裏是我的輸入文本框。
<input type="text" id = "hh_id" name = "hh_id" placeholder="Please enter Household ID" class = "form-control" href="<?=base_url('location/hh_members')?>">
<input type="text" id = "cli_hh_id" name = "cli_hh_id" class = "form-control" href="<?=base_url('location/cli_hh')?>">
這裏是關於#hh_id我的js。這裏沒有任何問題。
$(document)
.on('change', '#hh_id', function(){
var hh_id = this.value;
$.ajax({
url: $(this).attr('href') + '/' + hh_id,
dataType: 'json',
success:function(data){
console.log(data);
var html = "";
for (var i = 0; i < data.length; i++) {
html += "<option data-cli_hh_id = '"+data[i].cli_hh_id+"' data-entry_id = '"+data[i].entry_id+"' data-my_name = '"+data[i].my_name+"' data-sex = '"+data[i].sex+"' data-brgy = '"+data[i].brgy+"' data-muncity = '"+data[i].muncity+"' data-province = '"+data[i].province+"' data-region = '"+data[i].region+"' value='"+data[i].value+"'>"+data[i].value+"</option>";
};
$('#full_name').html(html);
}
});
});
這是我遇到我的問題,這是不被觸發時,它有它的價值。:(
$(document)
.on('change', '#cli_hh_id', function(){
alert('Is this loading?');
var cli_hh_id = this.value;
$.ajax({
url: $(this).attr('href') + '/' + cli_hh_id,
dataType: 'json',
success:function(data){
console.log(data);
var html = "";
for (var i = 0; i < data.length; i++) {
html += "<p>"+ data[i].key + " " + data[i].value+"</p>";
};
$('#cli_household').html(html);
}
});
});