Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于v5版本的一个问题。 #95

Open
cevin opened this issue May 28, 2014 · 0 comments
Open

关于v5版本的一个问题。 #95

cevin opened this issue May 28, 2014 · 0 comments

Comments

@cevin
Copy link

cevin commented May 28, 2014

        function ajax(cfg) {
            cfg = cfg || {};
            cfg.data = cfg.data || {};
            cfg.datatype = cfg.datatype || 'json';
            cfg.type = cfg.type || 'post';
            cfg.id = cfg.id || 'cevin';

            var dl = null;
            $.ajax({
                url:cfg.url,
                type:cfg.type,
                data:cfg.data,
                dataType:cfg.datatype,
                beforeSend: function(){
                    dl = art.dialog({id:cfg.id,content:'正在提交...',lock:true});
                },
                success:function(data){
                    dl.close();
                    dl = art.dialog({id:cfg.id,lock:true,content:data.msg});
                    console.log(dl);
                    if (data.code == 403) {
                        dl.button({name:'确定',focus:true,callback:function(){
                            window.location.href = data.msg;
                        }}).content('授权过期,请重新登录');
                    } else if(data.code != 1) {
                        dl.title('错误');
                    }
                    if (typeof(cfg.ok) == 'function') {
                        cfg.ok(data,dialog);
                    }
                },
                error:function(){
                    dl.close();
                    art.dialog({id:cfg.id}).title('错误').content('发生错误,操作失败').lock();
                },
                cache:false
            });
        }

如上代码。
ajax({id:'id',ok:function(){ajax({id:'other'})}}); 回调中再次执行的话,之前的窗口关闭了为什么?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant