在左侧菜单栏中,我有两个链接和消息,同时点击消息,它正在从服务器获取用户消息页面,它正常工作。 我想向用户显示一些图片作为加载符号,在哪里放置代码我没有得到它。 我正在使用以下ajax代码从服务器
获取消息页面 function getMessages(id)
{
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (typeof xmlhttp == "undefined")
{
ContentDiv.innerHTML="<h1>XMLHttp cannot be created!</h1>";
}
else{
var query='message?id='+id;
xmlhttp.open("GET",query,true);
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("profile-detail").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.send();
}
}
答案 0 :(得分:1)
1假设您有页面
<img id="ajaxImageCtrl" src="path/ajax.gif" />
2将此行放在var xmlhttp;
document.getElementById("ajaxImageCtrl").style.display = 'block'
3放这一行
document.getElementById("ajaxImageCtrl").style.display = 'none';
之后
document.getElementById("profile-detail").innerHTML=xmlhttp.responseText;
我希望这能完成这项工作