I would like to load with ajax the options of a select after onclick
I tried using onclick and click functions of jquery but doesn't work
$(".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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.