使用Ajax加载
问题描述:
我想在Ajax工作时添加加载图像。我已经有这个:使用Ajax加载
if(xml.readyState == 1) {
divPrincipal.innerHTML = "<img src='/RH/images/loading.gif' />"
}
if(xml.readyState == 2) {
divPrincipal.innerHTML = ""
}
它工作得很好,但它并没有把图像放在我想要的地方。
有没有办法将加载图片准确地放在中心和所有内容的前面?或者我应该插入一个div的位置,我想要的图像是?
非常感谢!
答
应用这些样式divPrincipal
:
#divPrincipal {
position: fixed;
left: 0; top: 0; right: 0; bottom: 0;
background: #cccccc;
background: rgba(255,255,255,0.5);
}
#divPrincipal > img {
position: fixed;
left: 50%;
top: 50%;
margin-left: -Xpx; /* where X is half the width of the image */
margin-top: -Ypx; /* where Y is half the height of the image */
}