【问题标题】:Why HTTP Requset abort or i can't get the response?为什么 HTTP 请求中止或我无法得到响应?
【发布时间】:2013-09-07 21:21:12
【问题描述】:

我正在尝试向 php 文件发送 HTTP 请求并获取用户名,因此在 while 循环中我在每个循环中发送一个请求,但是在 Firebug 中发生了请求中止的情况。

function getBody(){
        if(window.XMLHttpRequest){
            http = new XMLHttpRequest();
        }else{
            http = new ActiveXObject(microsoft.XMLHTTP);
        }
        limit =getC();
        i=1;
        while(i <= 50){
            http.onreadystatechange = function(){       
                    if(http.readyState == 4){
                        getPosts(http.responseText , i);
                    }
            }
            http.open("get","../php/php.php?q=getBody&id=comment"+i);       
            http.send();
            i++;
        }
    }

【问题讨论】:

  • 可以使用http.open("GET","...",false);同步请求。

标签: php javascript http xmlhttprequest firebug


【解决方案1】:

在firebug中检查http.open中的目的地在哪里

"../php/php.php?q=getBody&id=comment"+i

我认为这个参数需要修改,它发生在我身上很多 有时它也可以在本地主机中工作,但不能在线,反之亦然

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-24
    相关资源
    最近更新 更多