layui獲取父頁面的值拼接在url後面
阿新 • • 發佈:2021-01-16
技術標籤:ajax
獲取父頁面表格的值:
var ncuId = parent.$("#ncuId").val();
新增頁面拼接Ajax請求url:
//動態填充埠下拉框值 $.ajax({ url: 'ncuWorkScenePort/getNcuPort/' + ncuId, dataType: 'json', type: 'post', contentType: "application/json;charsetset=UTF-8",//避免415錯誤碼 success: function (data) { $.each(data, function (index, item) { $('#portNo').append(new Option(item.s_label, item.s_value));//下拉選單裡新增元素 }); layui.form.render("select"); //重新渲染 固定寫法 } });
完整程式碼:
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=f5bKSDjUlnYT4r664aQrQZB8&s=1"></script> <script> layui.use(['laydate', 'upload', 'form', 'layer','jquery'],function() { var layer = layui.layer ,$ = layui.jquery ,upload = layui.upload ,laydate = layui.laydate ,form = layui.form; var ncuId = parent.$("#ncuId").val(); //動態填充埠下拉框值 $.ajax({ url: 'ncuWorkScenePort/getNcuPort/' + ncuId, dataType: 'json', type: 'post', contentType: "application/json;charsetset=UTF-8",//避免415錯誤碼 success: function (data) { $.each(data, function (index, item) { $('#portNo').append(new Option(item.s_label, item.s_value));//下拉選單裡新增元素 }); layui.form.render("select"); //重新渲染 固定寫法 } }); </script>