//控制器

/// <summary>
        /// 下拉框
        /// </summary>
        /// <returns></returns>
        public ActionResult GetSelectType()
        {
            List<GoodsType> list = tbll.GetSelectType();

            return Json(list,JsonRequestBehavior.AllowGet);
        }
//视图

<select id="select1" name="TypeId" class="form-control">
                    <option>-请选择-</option>
                </select>

$(function () {
        load();
    })

    function load() {
        $.ajax({
            url: "https://localhost:44386/GoodsInfo/GetSelectType",
            type: "Get",
            success: function (data) {
                $(data).each(function () {
                    $("#select1").append('<option value=" ' + this.ID + '">' + this.TypeName + '</option>')
                })
            }
        })
    }
posted on 2019-11-21 15:33  .net之路  阅读(62)  评论(0编辑  收藏  举报