Contoh data di ambil dari
Sistem Data Dictionary Sektor Awam(SDDSA)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
$.ajax({
type: "get",
url: "https://www.azali.net/API/Jantina",
contentType: "application/json;charset=utf-8",
dataType: "json",
data: {},
success: function (result) {
$.each(result, function (i) {
$('#selJantina').append($('<option></option>').val(result[i].KodJantina).html(result[i].NamaJantina));
});
$('#selJantina').change();
},
failure: function () {
alert("Error");
}
});
$('#selJantina').change(function () {
$("#selectedJantinaVal").html($("#selJantina option:selected").val());
$("#selectedJantinaText").html($("#selJantina option:selected").text());
});
});
</script>
<h2>Jantina</h2>
<select id="selJantina"></select>
<div>
<h5>Selected</h5>
Value =<span id="selectedJantinaVal"></span><br />
Text =<span id="selectedJantinaText"></span>
</div>
Back to Demo