jQuery上传文件插件 - 如何在上传后重新加载页面?

时间:2017-02-07 14:55:11

标签: javascript jquery html

我在我的网站上使用此插件:http://hayageek.com/docs/jquery-upload-file.php

它运行良好,但我需要在成功上传后重新加载页面。有一些回调afterUploadAll也许可以做到,但我不知道如何实现它。

这是我的代码,如何将其添加到该代码中?:

<h1>Header</h1>
<div class="wrapper">
<div id="uploader">Upload</div>
</div>

<script>
$(document).ready(function()
{
    $("#uploader").uploadFile({
    url:"upload.php",
    fileName:"myfile",
    showDone:true,
    maxFileSize: 20971520,
    showFileCounter: false,
    }); 
</script>

2 个答案:

答案 0 :(得分:0)

尝试:

<script>
$(document).ready(function()
{
    $("#uploader").uploadFile({
    url:"upload.php",
    fileName:"myfile",
    showDone:true,
    maxFileSize: 20971520,
    showFileCounter: false,
    afterUploadAll: function(obj) {
        window.location = 'http://www.example.de';
    }
    }); 
</script>

答案 1 :(得分:0)

<script>
$(document).ready(function()
{
$("#uploader").uploadFile({
url:"upload.php",
fileName:"myfile",
showDone:true,
maxFileSize: 20971520,
showFileCounter: false,
afterUploadAll: function(obj) {
    window.location = 'YOUR URL HERE';
}
}); 

OR

 <script>
   $(document).ready(function()
   {
  $("#uploader").uploadFile({
url:"upload.php",
fileName:"myfile",
showDone:true,
maxFileSize: 20971520,
showFileCounter: false,
afterUploadAll: function(obj) {
    location.reload();
}
});