所以我有一个简单的AJAX请求(不是JQuery):
function ajaxfunction(){
var ajaxRequest;
try{
ajaxRequest = new XMLHttpRequest();
} catch (e){
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
alert("Your browser sucks"); //error
return false;
}
}
}
ajaxRequest.open("GET", 'pull.php?ms='+new Date().getTime(), true);
ajaxRequest.send(null);
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
}
我想请求也拉图片。由于请求是动态的(显示的图像会改变),所以我一遍又一遍地执行请求。然而,这使得图像闪烁。我试过<img src="foobar.jpg" style="visibility:none;" onLoad="this.style.visibility='visible';" />
,但没有什么帮助。如果有人知道任何修复,提前感谢你。: D
也许不是在ajax响应中拉整个<img>
标签,而是获取图像名称和属性来改变目标图像src
, height
, width
等…
我想知道在img标签的style属性中包含图像的高度和宽度是否会有所帮助,因为浏览器需要一秒钟才能开始下载图像并获得实际的图像高度和宽度