我正在使用 sumoselect ( http://hemantnegi.github.io/jquery.sumoselect/sumoselect_demo.html )。我有三個下拉菜單稱為countries, state, and cities. 國家/地區(qū)顯示在下拉列表中,onchange根據(jù)國家/地區(qū) ID 狀態(tài)名稱將顯示在下拉列表中。現(xiàn)在我的問題是,我沒有在下拉列表中獲得州名,而是在查看源代碼。檢查下圖。如果我從下拉列表中刪除 sum select 類,那么它就可以工作了。JS$('.search_sumo').SumoSelect({search: true, searchText: 'Enter here.'});$(".country_change").on('change',function(){ var country_id=$(this).val(); var select_list = $(this).data('target'); // The dropdown ID $.ajax({ url:baseUrl +"/System_control/statename", method:"POST", data:"country_id="+country_id, dataType: "json", success:function(data){ //alert(data); $('#'+select_list).empty(); var placeholder="<option value='' disabled selected>Select state</option>"; $('#'+select_list).html(placeholder); $.each(data, function(i, data) { $('#'+select_list).append("<option value='" + data.id + "'>" + data.state_name + "</option>"); }); } }); });HTML <select name="country" class="form-control search_sumo country_change" data-target="target_state_dropdown"> <option selected disabled=""> Select country</option> <?php foreach ($get_country as $row) {?> <option value="<?php echo $row->id; ?>" <?php echo set_select('country',$row->id,False);?>><?php echo $row->country_name;?></option> <?php }?> </select> <select name="state" class="form-control search_sumo state_get" id="target_state_dropdown" data-target="city_dropdown"> <option selected disabled=""> Select state</option> </select>任何人都可以幫我解決這個問題嗎?
如何在相撲選擇下拉列表中顯示ajax響應?
犯罪嫌疑人X
2021-08-20 17:36:39