Safari XHR upload stucks (sometimes)

半腔热情 提交于 2019-12-20 03:20:06

问题


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.


回答1:


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...



来源:https://stackoverflow.com/questions/6491512/safari-xhr-upload-stucks-sometimes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!