简体   繁体   中英

Dropdown populated using javascript showing only 'Undefined' in the dropdown options

I am using A javascript MEthod to populate Dropdown list as following but getting many 'Undefined' in my dropdown options-

<script type="text/javascript">
    function openPopup()
    {
        $("#wrapper").html('');
        $.get('getClanLeads', function(data){

         var options = '';
         $.each(data, function(i,data){
            options +='<option value="'+ data.user_id +'">' + data.user_id + '</option>';
        });
         $("#wrapper").append('<select>' + options + '</select>');
         alert(data);
         location.href = "#divModalDialog1";
        });
    }

</script>

options +='<option value="'+ data.user_id +'">' + data.user_id + '</option>';

Try change

data.user_id

to

data.user_id.value

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM