我想在onclick之后用ajax加载选择的选项
我尝试使用jquery的onclick和click函数,但是不起作用
$(".myselect").on("click", function() {
let thisv = $(this);
$.ajax({
url: "cargar_select_plazas",
dataType: "JSON",
type: "POST",
data: {
some: data
},
success: function(r) {
let html = "";
for (let x in r) {
html += `<option value="` + r[x].theid + `">` + r[x].thenameproduct + `</option>`;
}
$(thisv).html(html);
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select class="form-control custom-select myselect">
</select>
答案 0 :(得分:0)