dongxingdu9594 2014-12-28 15:07
浏览 737
已采纳

如何在ajax上传完成后刷新当前页面

I'm working on JS Ever ajax multiple image uploader. It works really great but one thing. I need the working page reload after all file finish upload. Yes, there's a function to do something after a file uploaded like : success, complete or done. But these callback is per file. It's mean if I add a reload function to it. The page will be reloaded right after the first file is finished upload.

I've tried.

complete:function(file,xhr){alert("ok")}

It works! But it's 3 ok popups since I uploaded 3 files. I need only one "OK" alert after the 3rd file is upload. Please suggest.

$('#uploader').JSAjaxFileUploader({
    uploadUrl: 'upload.php',
    complete: function (file, xhr) {
        $(alert("ok"));
    }
});

This is the DEMO.

  • 写回答

3条回答 默认 最新

  • doubeishuai6598 2014-12-28 15:15
    关注

    Can you just add a count?

    var count = 0;
    var length;
    
    $('#uploader').JSAjaxFileUploader({
      uploadUrl: 'upload.php',
      complete: function (file, xhr) { 
        if ( count === 0 ) {
          length = $('.JSpreveiw li').length;
        }      
        if ( count === length - 1 ) {
          alert('thanks for uploading!');
          window.location.reload();
        }
        count += 1;
      } 
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题