Can safari/chrome/opera make ajax requests while an upload is in progress?
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){
$('#upda开发者_Go百科teMe').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
As per I know there can be two request for one server domain can be active for the browser. That is if your server domain name is 'code.mydomain.com' then there can be atmost 2 request open at a time. In your case first one is file uploading request. You have to check do you have any other active request apart form uploading in specified browsers.
精彩评论