Ajax调用不成功

I am making a javascript function call on onclick of any checkbox like this:

function getPGCountList(pageNo) {
    var url = "someJsp.jsp?" + pageNo;
    alert(1);
    if (window.XMLHttpRequest) {
        alert(2);
        xmlhttp = new XMLHttpRequest();
    } else {
        alert(3);
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    alert(4);
    xmlhttp.onreadystatechange = function () {
        alert(5);
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            alert(6);
            document.getElementById("searchForPage").innerHTML = xmlhttp.responseText;
        }
    };
    alert(7);
    xmlhttp.open("GET", url, true);
    alert(8);
    xmlhttp.send();
}

The alert output I am getting is at my hosted site:

1-2-4-7-5-8-5-5-5

But in my local system it is:

1-2-4-7-5-8-5-5-5-6

I need to execute alert 6 also to change the content. I am not sure where is the problem?

Your code looks fine to me. Check the path to someJsp.jsp It's obviously not returning a normal response from the ajax call otherwise it would enter your if block and fire alert 6.

Just a thought too, but if you alert xmlhttp.readyState and xmlhttp.status maybe it'll help you find your problem. IF they are undefined, or refer to an object that is undefined, then your new XMLHttp requests failed. IF they give you results, you can see what the responses mean