Jquery 依赖下拉列表以加载到文档就绪
Jquery Dependent Dropdown to load on document ready
您好,我有一个针对国家/地区和城市的下拉列表,我想根据国家/地区加载州和城市 文档就绪函数 我试图放置 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。
相关文章:
- Ajax请求文档就绪会导致jquery加载缓慢
- 文档就绪提供了错误的选择器高度
- 函数不't在jquery文档就绪时执行
- 如何在文档就绪 .fileupload 中分配值
- 在文档就绪时触发更改事件
- 在文档就绪时追加DDL;不要让它在列表项上有CSS,而不让它们可排序
- 文档就绪var未知
- 一种JavaScript,可在文档就绪时自动点击flash对象
- 文档就绪按钮.单击仅在控制台中有效
- 函数在文档就绪时无法正常工作
- 文档就绪功能 - 不先加载代码
- 如何将文档就绪函数放置在 ajax 函数中
- 在文档就绪的JavaScript上计算
- 如果选中所有子复选框,如何选中父复选框 - 在文档就绪时
- JavaScript 文档就绪函数
- 如何在文档就绪函数下使用回调函数
- JSNI (GWT-GWTP):jQuery在就绪事件触发后不会在“文档就绪”函数中选择节点
- 在文档就绪上运行 PHP 函数
- jQuery的触发器方法在文档就绪上无法正常工作
- jquery文档就绪侦听器与图像加载;执行顺序