Javascript 如何关闭模型弹出窗口jquery

Javascript 如何关闭模型弹出窗口jquery,javascript,ajax,jquery,modal-dialog,Javascript,Ajax,Jquery,Modal Dialog,我在我的查看页面上有一个按钮,每当它被点击时,就会出现一个弹出模式。。。现在我想关闭这个模式 这是我的密码 function openSirenModal() { var timeout; var progress; var status; $.modal({ contentAlign: 'center', width: 240, title: 'Loading', content: '<div style="line-height: 25px; padd

我在我的查看页面上有一个按钮,每当它被点击时,就会出现一个弹出模式。。。现在我想关闭这个模式

这是我的密码

function openSirenModal() {
var timeout;
var progress;
var status;

$.modal({
    contentAlign: 'center',
    width: 240,
    title: 'Loading',
    content: '<div style="line-height: 25px; padding: 0 0 10px"><span id="modal-status">Contacting to the device...</span><br><span id="modal-progress">0%</span></div>',
    buttons: {},
    scrolling: false,
    actions: {
        'Cancel': {
            color: 'red',
            click: function (win) {
                win.closeModal();
            }
        }
    },
    onOpen: function () {
        // Progress bar
        var progress = $('#modal-progress').progress(100, {
            size: 200,
            style: 'large',
            barClasses: ['anthracite-gradient', 'glossy'],
            stripes: true,
            darkStripes: false,
            showValue: false
        }),

            // Loading state
            loaded = 0,

            // Window
            win = $(this),

            // Status text
            status = $('#modal-status'),

            // Function to simulate loading
            simulateLoading = function () {




            };

        // Start
        //timeout = setTimeout(simulateLoading, 2500);
    },


    onClose: function () {
        // Stop simulated loading if needed
        clearTimeout(timeout);
    }


});

var siren = "siren";
$.ajax({
    type: "POST",
    data: {
        value: siren
    },
    url: "http://localhost/siren/siren/",

    success: function (data) {
        alert(data);
        if (data == 1) {

            var auto_refresh = setInterval(
                function () {
                    $.get('siren/sirenjson', function (datas) {

                        if (datas == 1) {

                            $('#modal-progress').hideProgressStripes().changeProgressBarColor('green-gradient');
                            $('#modal-status').text('success!');
                            setTimeout(function () {
                                clearInterval(auto_refresh);
                                win.closeModal();//here i want to close the popup modal
                            }, 1500);


                        }
                    });

                }, 1000);





        } else {

        }

        //clearTimeout(timeout);
    },
    error: function () {

        alert("error");
        progress.hideProgressStripes().changeProgressBarColor('red-gradient');
        setTimeout(function () {
            win.closeModal();
        }, 1500);
        status.text('error!');
    }
});

 };
函数openSirenModal(){ var超时; var进展; var状态; 美元模态({ contentAlign:“中心”, 宽度:240, 标题:“加载”, 内容:“正在联系设备…
0%”, 按钮:{}, 滚动:false, 行动:{ “取消”:{ 颜色:“红色”, 点击:功能(win){ win.closeModal(); } } }, onOpen:函数(){ //进度条 变量进度=$(“#模式进度”)。进度(100{ 尺寸:200, 风格:'大', 棒类:[“无烟煤梯度”,“光滑”], 是的, 黑暗:错误, showValue:false }), //加载状态 已加载=0, //窗口 win=$(此), //状态文本 状态=$(“#模式状态”), //函数来模拟加载 SimulateLoad=函数(){ }; //开始 //超时=设置超时(模拟加载,2500); }, onClose:function(){ //如果需要,停止模拟加载 clearTimeout(超时); } }); var siren=“siren”; $.ajax({ 类型:“POST”, 数据:{ 价值:警笛 }, url:“http://localhost/siren/siren/", 成功:功能(数据){ 警报(数据); 如果(数据==1){ var auto_refresh=setInterval( 函数(){ $.get('siren/sirenjson',函数(数据){ 如果(数据==1){ $(“#模式进度”).hideProgressStripes().changeProgressBarColor('green-gradient'); $(“#模态状态”).text('success!'); setTimeout(函数(){ clearInterval(自动刷新); win.closeModal();//这里我想关闭弹出模式 }, 1500); } }); }, 1000); }否则{ } //clearTimeout(超时); }, 错误:函数(){ 警报(“错误”); progress.hideProgressStripes().changeProgressBarColor('red-gradient'); setTimeout(函数(){ win.closeModal(); }, 1500); status.text('error!'); } }); }; 我已经编写了win.closeModal()代码;但它不起作用,因为我无法在setInterval中访问win变量。我不知道如何访问它
<div id="modal">Modal text <br /><button type='button' class='close'>CLOSE</button></div>

$('.close').on('click', function(){ 
         $.modal.close();
         $('#modal, #open_modal').toggle();
    });
$('.close')。在('click',function(){ $.modal.close(); $(“#模式,#打开#模式”).toggle(); }); 如果可以跳过
closeModal(),请尝试此操作


是否要使用closeModal();。。。或者,您也可以通过向该模式添加close div来关闭该模式。我只想关闭该模式。。如果我不使用设置间隔,那么它会工作,否则它不会工作。我只想关闭模式。。如果我没有指定时间间隔,那么我可以关闭它。。但是在间隔时间内,它不起作用。我不想点击任何东西来关闭模式。。我只想在成功消息出现后自动关闭模式。。。用定时器试试这个,bcoz如何知道它是否成功?我对javascript没有太多经验。。所以我只想用这个模态。。好吧,我提交的其他代码中,模态是关闭罚款。。。我定制了那个代码