简体   繁体   English

jQuery上传完成后重定向到新页面

[英]Redirect to new page after jquery uploads done

I am trying to get this jquery tool to work with my website for file uploads: https://github.com/blueimp/jQuery-File-Upload and I have it working for the most part. 我正在尝试使这个jquery工具与我的网站一起使用来上传文件: https : //github.com/blueimp/jQuery-File-Upload,而我大部分时间都在使用它。 The only issue I am having is trying to find a place where I can make it redirect to a new page to display the results of the upload instead of displaying them on the same page. 我遇到的唯一问题是试图找到一个可以重定向到新页面的位置,以显示上载的结果,而不是在同一页面上显示它们。 I want to have the option for the users to do things with the images and files they just uploaded, and a new page makes more sense for this than using the same page over and over and over again... 我希望用户可以选择使用他们刚刚上传的图像和文件来做事,并且新页面比一遍又一遍地使用同一页面更有意义。

Can anyone tell me from experience of understanding something in the documentation/code that I didn't grasp on how I can do this? 谁能从我了解到的文档/代码中无法理解的经验中告诉我? Thanks :) Please note that i want the page to be redirected at the end of ALL of the uploads and not after the first if there are four more. 谢谢:)请注意,如果要再上传四个文件,我希望页面在所有上传的末尾而不是在第一个之后被重定向。 I will be storing the data in a PHP session to access on the next page. 我将把数据存储在PHP会话中以在下一页进行访问。

Should be like this (in this case redirecting to http://stackoverflow.com ): 应该是这样的(在这种情况下,重定向到http://stackoverflow.com ):

<script>
$(function () {
    $('#fileupload').bind('fileuploadstop', function (e) {/* ... */});

});
</script>

Check out the docs . 查看文档

<script>
$(function () {
    $('#fileupload').fileupload({
        // ... additional parameters
        complete: function (e, data) {
            window.location = "http://www.stackoverflow.com";
        }
    });
});
</script>

The plugin has an events called onComplete and onCompleteAll . 该插件有一个名为onCompleteonCompleteAll的事件。 Use them. 使用它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM