gpt4 book ai didi

php - 在页面加载时选择选项加载时触发事件

转载 作者:行者123 更新时间:2023-12-01 04:37:41 26 4
gpt4 key购买 nike

我想获取基于所选行业类型的业务类型列表。我正在使用以下代码 -

$('#industry_type').change(function () {
var industry_id = $(this).val();
getBusinessTypes(industry_id);
return false;
});

function getBusinessTypes(industry_id) {
$.ajax({
url: baseURL + ('processes/org_process.php'),
type: "POST",
data: { 'action': 'all', 'industry_id': industry_id },
success: function (data) {
var business_type = $('#business_types');
business_type.chosen('destroy');
business_type.html(data);
business_type.chosen({ width: "100%" });
}
});
}

这将返回业务类型列表。

这里的问题是只有在更改选择选项时才会触发该事件。如果页面加载时已选择选择选项,则不会触发该事件。

有人知道如何根据页面加载时选定的行业类型获取业务类型列表吗?

谢谢!

最佳答案

绑定(bind)事件处理程序后添加.trigger('change')

$('#industry_type').change(function () {
var industry_id = $(this).val();
getBusinessTypes(industry_id);
return false;
}).trigger('change');

关于php - 在页面加载时选择选项加载时触发事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46940515/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com