1. 程式人生 > >動態新增select裡的選項

動態新增select裡的選項

 var selDom = $("#id");
    $.ajax({
        url: "../aaaaa/aaaaaaa.ht",
        type: 'post',
        dataType: 'json',
        data: {"role": "YZ"},
        async: false,
        success: function (data) {
            console.log(data);
            var json = eval(data);
            $.each(json, function (key, value) {
                selDom.append("<option value=" + data[key].police_num + ">" + data[key].name + "</option>");
            });
        }
    });