populate dropdown using jquery from database

Solutions on MaxInterview for populate dropdown using jquery from database by the best coders in the world

showing results for - "populate dropdown using jquery from database"
Léa
26 Jan 2020
1Use a string to store your option, and then append it to the select tag. Then, please check that data is there in the val.
2
3$.getJSON("get-data.php?dat=driver",function(data){
4    var stringToAppend = "";
5    $.each(data,function(key,val) {
6
7       stringToAppend += "<option value='" + val.id + "'>" + val.id + "</option>";
8
9    });
10
11    $("#night_Shift_text").html(stringToAppend);
12});