同时发出2个Ajax请求?

时间:2013-08-13 20:22:34

标签: javascript ajax

我想发一个ajax请求从数据库中获取一些数据,然后将该数据发送到另一个文件,这将返回另一个结果。似乎没有用,第一个Ajax请求工作正常,但是第一个返回结果时触发的第二个请求没有做任何事情。

var http = getHTTPObject();
    var http2 = getHTTPObject();
    ids = fetchSelection().toString();

    //Make button animate, visual aid that it is working
    obj.src = "http://localhost/nightclub_photography/images/buttons/"+dir+"_animated.gif";

    http.onreadystatechange = function() 
    {
        if (http.readyState == 4 && http.status == 200) {
            http2.onreadystatechange = function() 
            {
                if (http2.readyState == 4 && http2.status == 200)
                {
                    alert("hello");
                }
            }
            http2.open("GET", "http://localhost/nightclub_photography/net/test2.aspx");
            http2.send();
        }
    }
    http.open("GET", "http://localhost/nightclub_photography/asp/returnDatabaseData.asp?ids="+ids);
    http.send();

1 个答案:

答案 0 :(得分:1)

test.aspx返回错误,因为我忘记传递它正在寻找的URL变量。傻傻的,谢谢你们!