Safari XHR上传stucks(有时) [英] Safari XHR upload stucks (sometimes)

查看:161
本文介绍了Safari XHR上传stucks(有时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 jquery-File-Upload 构建上传脚本。



现在我有一个奇怪的行为,上传时不时(比方说,每八分之一)。这只发生在Safari(5.0.5),其他浏览器工作正常。

我可以确认这不是服务器相关的。在执行任何服务器脚本之前,这个问题都会出现。



有时候上传的时间是2%,有时候是82%。

另外我觉得很难调试。当使用 Charles 时,问题接缝消失。



有关问题和调试策略的任何帮助都会得到赞赏。

解决方案

结果发现这个解决方案通过 Ben 解决了这个问题。



如果您使用 jquery-File-Upload ,它看起来像这样(警告:我使用 v4版本):

  $(function(){
$('#file_upload')。fileUploadUI({
//其他一些代码
beforeSend :function(event,files,index,xhr,handler,callBack){
$ .ajax({
async:false,
url:'closeconnection.ph p'
});
callBack();
}
});
});

其中相应的php脚本如下所示:

 <?php 
header(Connection:Close);
?>

WTF ??

这是否与Safari缓存有关?或者仍然打开POST请求?让我知道,如果你有任何想法... ...

I build a upload script using jquery-File-Upload.

Now I have the weird behavior that the upload stucks from time to time (let's say every eighth time). This only happens in Safari (5.0.5), other browsers are working fine.

I can confirm that this is NOT server related. The problem accours before any server scripts are executed.

Sometimes the upload stucks at 2%, sometimes at 82%.

Also I find it hard to debug. When using Charles the problem seams to disappear.

Any help regarding the issue and debugging strategies appreciated.

解决方案

Turns out that this solution by Ben fixes the issue.

In case you use jquery-File-Upload it looks like this (caution: i'm using the v4 version):

$(function () {
        $('#file_upload').fileUploadUI({
            //some other code
            beforeSend: function (event, files, index, xhr, handler, callBack) {
                $.ajax({
                    async: false,
                    url: 'closeconnection.php'
                });
                callBack();
            }
        });
    });

Where the corresponding php script looks like this:

<?php
    header("Connection: Close");
?>

WTF??

Does this has something to do with Safari caching? Or with still open POST requests? Let me know if you have any idea...

这篇关于Safari XHR上传stucks(有时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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