您好,我有一个针对国家/地区和城市的下拉列表,我想根据国家/地区加载州和城市 文档就绪函数 我试图放置 document.ready (function())
但是没有任何效果,请更新我如何使用它
我的代码在这里
function showState(sel) {
var country_id = sel.options[sel.selectedIndex].value;
$("#output1").html( "" );
$("#output2").html( "" );
if (country_id.length > 0 ) {
$.ajax({
type: "POST",
url: "fetch_state.php",
data: "country_id="+country_id,
cache: false,
beforeSend: function () {
$('#output1').html('<img src="images/loading.gif">');
},
success: function(html) {
$("#output1").html( html );
}
});
}
}
function showCity(sel) {
var state_id = sel.options[sel.selectedIndex].value;
if (state_id.length > 0 ) {
$.ajax({
type: "POST",
url: "fetch_city.php",
data: "state_id="+state_id,
cache: false,
beforeSend: function () {
$('#output2').html('<img src="images/loading.gif">');
},
success: function(html) {
$("#output2").html( html );
}
});
} else {
$("#output2").html( "" );
}
}
您可以在"城市/州选择"部分尝试选择.js。