getSupplierTypeForSpinner("supplierTypeID","",true,true); function getSupplierTypeForSpinner(ctrlID, selectVal, isViewAll,isAsync) { $.ajax({ url: basePath +"ba/supplier_type/getSupplierTypeForSpinner", type: "post", async: isAsync, success: function (data) { $("#" + ctrlID + "").empty(); $("#" + ctrlID + "").append("<option value=''></option>"); if (isViewAll) { $("#" + ctrlID + "").append("<option value=''> 查看全部</option>"); } $.each(data, function (i, item) { $("#" + ctrlID + "").append("<option value='" + item.supplier_type_id + "'>" + item.supplier_type_name + "</option>") }); if (selectVal != "") { $("#" + ctrlID + "").val(selectVal); } $("#" + ctrlID + "").select2({placeholder: "--请选择供应商类型--"}); } }); }