问题
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