1. 程式人生 > >jsp頁面點選彈出iframe彈框,並傳值到後臺

jsp頁面點選彈出iframe彈框,並傳值到後臺

 function openwindow(id,endDate){
                    layer.open({
                        type: 2,
                        title: false,
                        closeBtn: 0, //不顯示關閉按鈕
                        shade: [0],
                        id:"_layerDialog"//這裡表示當前頁面的ID
                        area: ['700px', '900px'],
                        //2秒後自動關閉
                        anim: 2,
                        btn: ['確定','關閉'],
                        content: ['${ctx}/superviseSum/delayOpenWindow?id='+id+'&endtime='+endDate, 'no'], //iframe的url,no代表不顯示滾動條,這個路徑跳到後臺獲取值,然後跳//到iframe彈框的頁面
                        yes:function(index,layero){
                            var _layerDialog = $("#_layerDialog").find("iframe").contents();//當前頁面ID去找iframe框架的內容

                            $.ajax({
                                cache: true,
                                type: "POST",
                                url:"${ctx}/superviseSum/delay"//這個路徑是提交後臺儲存的
                                data:_layerDialog.find('#inputForm1').serialize(),// 你的formid,這裡的inputForm1是指另一個頁面form的ID,獲取另一個jsp表單所有的值

                                async: false,
                                error: function(request) {
                                    layer.msg("稽核操作失敗", {time: 2000});
                                },
                                success: function(data) {
                                    if(data!=1){
                                        layer.msg("稽核操作失敗", {time: 2000});
                                        setTimeout(function(){
                                            window.location.href="${ctx}/superviseSum/detail?id=${superviseSum.id}";
                                        },1500)
                                    }else {
                                        layer.msg("稽核操作成功", {time: 2000});
                                        setTimeout(function(){
                                            window.location.href="${ctx}/superviseSum/detail?id=${superviseSum.id}";
                                        },1500)
                                    }
                                }
                            });
                            layer.close(index);
                        },
                    })
                }