PHP多个Ajax请求:一是请求块第二个请求 [英] PHP Multiple Ajax requests: First request block second request

查看:154
本文介绍了PHP多个Ajax请求:一是请求块第二个请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在一个页面上2 Ajax请求。我跑第一个请求,并分别启动第二个。但第二次停止后的第一个已运行工作。并不断时,首先就结束了。 首先requst需要很长时间 - 有点像30 - 60秒,就在这个时候,我需要第二个请求,以显示日志与第一个请求会发生什么。我尝试使用异步:真实的,但它不是帮助我

I've got 2 ajax requests on one page. I ran first request and separately start second one. But second one stops working after the first has been run. And continue when first is over. First requst take long time - something like 30 - 60 seconds and in this time I need second request to show logs what happens with first request. I try to use async: true but it's not help me.

这是我的code

<script type="text/javascript">
    var auto_refresh = setInterval( function()
        { asyncGet('log.php') }, 1000
    );

    function asyncGet(addr) {
        $.ajax({
            url: addr,
            async: true,
            success: function (response) {
                $('#loadLog').html(response);
            }
        });
    }

    function getConn(addr) {
        $.ajax({
            url: addr,
            async: true,
            success: function (response) {
                stopGet();
            }
        });
    }


</script>

<div id="loadLog" class="lLog"></div>

和我称这种方式第一Ajax请求:getConn('main.php');从功能时,preSS按钮。 第二个请求它的运行,但在此之前没有表现出respons第一个请求完成。

and I call first ajax request in this way: getConn('main.php'); from function when press button. Second request it's running, but not show respons before first request complete.

我也将由萤火附加图片。 main.php - 是请求花费更长的时间。 log.php - 是阻止记录器

I wil attach image from firebug. main.php - is request that take longer time. log.php - is the logger that is blocked.

真的AP preciate一些指针,以我要去哪里错了。

Would really appreciate some pointers to where I'm going wrong

推荐答案

这可能是会议的一个问题。看看这个帖子。假设你可能需要在main.php快速关闭会话越好。

This may be a problem with session. Check out this post. Suppose you may need to close session in your main.php as fast as possible.

这篇关于PHP多个Ajax请求:一是请求块第二个请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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