<script>
$(document).ready(function() {
// Initialize Select2
$('#nameDropdown').select2({
placeholder: 'Select a name',
width: '300px',
minimumInputLength: 0,
ajax: {
url: 'get_names.php', // Provide the URL to fetch data from the server
dataType: 'json',
processResults: function(data) {
return {
results: data
};
}
}
});
});
</script>