Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Bom, estou com o seguinte problema:
preciso gerar um background a partir de Ajax só que o ajax não me retorna a imagem somente texto.
Estou usando o código abaixo:
try {
ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
try {
ajax = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(ex) {
try {
ajax = new XMLHttpRequest();
}
catch(exc) {
alert("Esse browser não tem recursos para uso do Ajax");
ajax = null;
}
}
}
hPage=document.body.clientHeight;
wPage=document.body.clientWidth;
ajax.open("GET",'geraBgBase.php?img=img/bgs/30.jpg&h='+hPage+'&w='+wPage, true);
ajax.send(null);
ajax.onreadystatechange = function(){
if(ajax.readyState==4){
img = new Image();
img.src = ajax.responseText;
document.body.style.background='url('+img.src+')';
}
}alguem poderia me ajudar por favor?
Obrigado
o img.src me retorna http://localhost/.../... /temp/%D1%8F%D0%A8%D1%8F%D0%B0
Carregando comentários...