bootstrap模态框动态赋值, ajax异步请求数据后给id为queryInfo的模态框赋值并弹出模态框(JS)
/查询单个 function query(id) { $.ajax({ url : "/small/productServlet", async : true, type : "POST", data : { "type" : "query", "id" : id }, // 成功后开启模态框 success : showQuery, error : function() { alert("请求失败"); }, dataType : "json" }); } // 查询成功后向模态框插入数据并开启模态框。data是返回的JSON对象 function showQuery(data) { $("#name1").val(data.name); $("#xinghao1").val(data.xinghao); $("#address1").val(data.address); $("#department1").val(data.department); $("#unit1").val(data.unit); $("#number1").val(data.number); $("#price1").val(data.price); $("#totalprice1").val(data.totalprice); $("#come1").val(data.come); $("#buytime1").val(data.buytime); $("#useperson1").val(data.useperson); $("#handleperson1").val(data.handleperson); $("#admini1").val(data.admini); // 显示模态框 $('#queryInfo').modal('show'); }
赞赏码
非学,无以致疑;非问,无以广识