在完成Ajax重定向右窗口之后

编程入门 行业动态 更新时间:2024-10-27 14:34:01
本文介绍了在完成Ajax重定向右窗口之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我从这个答案中实现我的代码,在webkit上进行表单上传,并且运行良好。 stackoverflow/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. stackoverflow/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重定向右窗口之后

本文发布于:2023-10-10 12:03:33,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   窗口   Ajax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!