jquery - 选择选项未更新
问题描述
我正在尝试根据 Country 先前的选择来更新城市的选择
警报正在从 json 响应中正确显示该选项。
$('#property_country').change(function() {
var selectedCountryId = this.value;
var $city = $('#property_city');
var options = "";
$.ajax({
url: 'Lookup',
method: 'GET',
data: {
action: "getCities",
countryId: selectedCountryId
},
dataType: 'json'
}).done(function(jsonResponse) {
$.each(jsonResponse, function(index, item) {
$.each(item, function(index, item) {
console.log(item.CityId + " " + item.CityName);
options = options + '<option value="' + item.CityId + '"> ' + item.CityName + '</option>';
});
});
alert(options);
$city.html(options);
});
});
解决方案
推荐阅读
- java - 在类型化映射中插入值
- google-kubernetes-engine - Google Kubernetes Engine 上的 kubectl 命令超时
- regex - 带有负匹配的正则表达式
- javascript - JQuery 使 BootStrap DropDown 菜单打开类 Go Away / Collapse
- java - 如何在 JTable 中使用 Jtable 列按钮渲染来渲染图像?
- knockout.js - 如何在间隔时间后重新加载函数
- ios - 如何在 UITableView 中获取动态大小的节标题的高度?
- azure - Power Shell:尝试将用户添加到组时使用变量
- html - 检查是否使用 excel VBA 检查网站复选框
- java - 为什么这个 Java 程序比它的 Ada 程序快 1000 倍?