Answers for "populate dropdown using jquery from database"

0

populate dropdown using jquery from database

Use a string to store your option, and then append it to the select tag. Then, please check that data is there in the val.

$.getJSON("get-data.php?dat=driver",function(data){
    var stringToAppend = "";
    $.each(data,function(key,val) {

       stringToAppend += "<option value='" + val.id + "'>" + val.id + "</option>";

    });

    $("#night_Shift_text").html(stringToAppend);
});
Posted by: Guest on March-12-2021

Code answers related to "populate dropdown using jquery from database"

Code answers related to "Javascript"

Browse Popular Code Answers by Language