Basically i am making a simple ajax request
function upload(){
setInterval(function callMeOften()
{
$.ajax({
method: 'get',
url : 'uploadinfo.php?unique_id=<?php echo $some_uniq_id; ?>',
dataType : 'text',
success: function(text){ updatebar(text); },
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest.status);
alert(XMLHttpRequest.responseText);
}
});
}, 5000);
}
function updatebar(per){
$('#updateMe').animate({"width" : per});
}
to a php script
$unique_id = $_GET['unique_id'];
$progress = uploadprogress_get_info($unique_id);
if(function_exists("uploadprogress_get_info")) {
if (floor(($progress['bytes_total']/1024)/1024) > 100){
echo "run";
} else {
if ($progress['bytes_uploaded'] == 0 || $progress['bytes_total'] == 0){
echo "100";
} else {
echo floor($progress['bytes_uploaded'] / $progress['bytes_total'] * 100);
}
}
}
This function upload(); is called using the onsubmit(); action of a file upload form
<form id="something" onsubmit="upload();" action="status.php" enctype="multipart/form-data" method="post">
I am using relative paths and the request works in FF and IE, but in chrome, safari and opera the ajax requests are not even fired while the upload is in progress.
What's going on?
EDIT: In the end i just showed the upload progress in a separate window that was created using the onsubmit action and re-sized and reposition to the center of the screen, looks alright and is by far the easiest way