为什么加载程序未以HTML显示?

我有一个AJAX文件,在加载内容时,我使用加载器图像来显示它。但是,尽管显示了文本,但有的内容还是没有显示出来,这是有问题的!

我的代码是:

http.onreadystatechange = function() {
    if(http.readyState == 4) {
        //document.getElementById("showBusStatus"+bus_id).innerHTML = http.responseText;
        document.getElementById("showBusStatus").style.color = '#999;';
        //document.getElementById("showBusStatus").style.input.width = '60px;';
        document.getElementById("showBusStatus").innerHTML = http.responseText;
    }
    else {
        document.getElementById("showBusStatus").innerHTML = '<img src="ajax-loader.gif"> Loading Content...';
    }
}

图像文件与Javascript文件位于同一目录。

Use a URL that is relative to the webroot.

<img src="/css/images/ajax-loader.gif" />

What you have works - but I suspect the image src is not specified correctly ... see this example jsfiddle it works fine using your code and a loading image found on the web.

JavaScript :

http.onreadystatechange = function() {
    if (http.readyState == 4) {
        document.getElementById("showBusStatus").style.color = '#999;';
        document.getElementById("showBusStatus").innerHTML = "Load complete";
    }
    else {
        document.getElementById("showBusStatus").innerHTML = '<img src="http://drupal.org/files/54640843-ajax-style-loading-gif-animation.gif" /> Loading Content...';
    }
};