在完成Ajax重定向右窗口之后 [英] After I'm done with Ajax redirect the right window

查看:111
本文介绍了在完成Ajax重定向右窗口之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从这个答案中实现我的代码,在webkit上进行表单上传,并且运行良好。
https://stackoverflow.com/a/16200886/548558



如果表单有效但是重定向发生在iframe中,我的后端给了我一个重定向,但是我真的想让它成为普通窗口。我如何做到这一点?任何人都有想法?

CODE

 <$ c $提交(函数(){
//防止多次提交
if($ .data(this,' ());
//更新进度条
函数update_progress_info(){
// $ progress.show();
$ .getJSON(progress_url,{'X-Progress-ID':uuid},function(data,status){
if(data){
var progress = parseInt(data.uploaded)/ parseInt(data.length);
var width = $ progress.find('。progress-container')。width()
var progress_width = width * progress;
$ progress.find('。progress-bar')。width(progress_width);
$ progress.find('。progress-info')。text('uploading'+ parseInt进度* 100)+'%' );
console.log(progress)
console.log(progress)
window.setTimeout(update_progress_info,freq);
}
});
};
window.setTimeout(update_progress_info,freq);

$ .data(this,'submitted',true); //将表单提交给
});
});


解决方案

如果我的理解是你的问题,做成一个 iframe ,你必须去你的窗口组件,调用他的父项(这个 iframe )并调用他的方法 location href 。我不得不使用这个,并为我工作。



window.parent.location.href =/foo.html


I was implementing my code from this answer to do Ajax calls in webkit on a form upload and it works well. https://stackoverflow.com/a/16200886/548558

My backend gives me a redirect if the form is valid but the redirect is happen in the iframe but I really want to have it the normal window. How I can do this? Anybody has an idea?

CODE

$(function() {
    $('#upload-form').submit(function() {
        // Prevent multiple submits
        if ($.data(this, 'submitted')) return false;
        $(this).prop("target", "file-upload");
        // Update progress bar
        function update_progress_info() {
            // $progress.show();
            $.getJSON(progress_url, {'X-Progress-ID': uuid}, function(data, status) {
                if (data) {
                    var progress = parseInt(data.uploaded) / parseInt(data.length);
                    var width = $progress.find('.progress-container').width()
                    var progress_width = width * progress;
                    $progress.find('.progress-bar').width(progress_width);
                    $progress.find('.progress-info').text('uploading ' + parseInt(progress*100) + '%');
                    console.log("progress")
                    console.log(progress)
                    window.setTimeout(update_progress_info, freq);
                }
            });
        };
        window.setTimeout(update_progress_info, freq);

        $.data(this, 'submitted', true); // mark form as submitted
    });
});

解决方案

If your call, if I understood your question, is made into an iframe, you must go to your window component, call to his parent (the container of this iframe) and call his methods location and href. I had to use this a few time ago and worked for me.

window.parent.location.href = "/foo.html"

这篇关于在完成Ajax重定向右窗口之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆