Can safari/chrome/opera make ajax requests while an upload is in progress?

柔情痞子 提交于 2019-12-07 10:52:58

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/3185238/can-safari-chrome-opera-make-ajax-requests-while-an-upload-is-in-progress

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