可以Safari /铬/歌剧发出Ajax请求,同时上传过程中? [英] Can safari/chrome/opera make ajax requests while an upload is in progress?

查看:176
本文介绍了可以Safari /铬/歌剧发出Ajax请求,同时上传过程中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我想提出一个简单的Ajax请求

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});

        }

PHP脚本

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);

    }

}

}

此功能上传();使用的onsubmit()被调用;文件上传表单的作用

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

我使用相对路径和要求工作在FF和IE浏览器,但在Chrome,Safari和Opera的Ajax请求,甚至没有解雇而上传正在进行中。

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.

这是怎么回事?

编辑:最后我只是表现在使用的onsubmit行动,并重新调整大小和重新定位到屏幕的中心创建一个单独的窗口中上传进度,看上去没事,是迄今为止最简单的方法。

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

推荐答案

根据我知道可以有两个要求一个服务器域可以是活动的浏览器。也就是说,如果您的服务器域名为code.mydomain.com,那么就不可能有atmost 2请求,同时打开。你的情况首先是文件上传请求。你必须检查你有没有任何其他的主动要求分开的形式上传指定的浏览器。

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.

这篇关于可以Safari /铬/歌剧发出Ajax请求,同时上传过程中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆