select 下拉源动态赋值

1

 function getA(data) {
            $.ajax({
                url: '/A/A/',
                data: { 'A': data },
                async: false,
                type: 'GET',
                dataType: 'JSON',
                success: function (re) {
                    var obj = JSON.parse(re.msg1);
                    $("#A").find("option[value='" + obj[0].A+ "']").attr("selected", "selected");
                    var obj = JSON.parse(re.msg2);
                    var htmstr = "";
                    for (i = 0; i < obj.length; i++) {
                        htmstr += "<option value='" + obj[i].A+ "'>" + obj[i].B+"</option>";
                    }
                    $('#A').html(htmstr);
                    layui.form.render("select");
                }
            });


        }

 

posted @ 2020-10-19 13:08  waityu  阅读(315)  评论(0编辑  收藏  举报