Mi sembra che stai facendo un po' di confusione... cosi si fa fatica a seguirti, è solo un esempio quello che hai postato? perche se quello che devi fare è presentare nel div la risposta ajax ti basta fare cosi:
codice:
window.addEvent("domready", function(){
function show(){
new Request({
url:"js/imgs.xml",
update:$("ajax"),
onRequest:function(){ $("ajax").set("html","WAITING FOR ANSWER..."); },//onRequest
onProress:function(event, xhr){ $("ajax").set("html", event.total); },
onSuccess:function(txt, xml){
var root = xml.documentElement;
imgs = root.getElementsByTagName("img");
img = (Browser.Engine.trident)? imgs[num].text : imgs[num].textContent;
$("ajax").set("html", "OK - "+root.getElementsByTagName("img").length+" - "+img);
$("divTest").set("html", img);
},
onFailure:function(){ $("ajax").set("html","ERROR"); }
}).send(null);
}
show();
)};//END "domready"
Se invece il codice corretto era quello di prima ti basta fare cosi:
codice:
window.addEvent("domready", function(){
function show(num){
var img;
new Request({
url:"js/imgs.xml",
update:$("ajax"),
onRequest:function(){ $("ajax").set("html","WAITING FOR ANSWER..."); },//onRequest
onProress:function(event, xhr){ $("ajax").set("html", event.total); },
onSuccess:function(txt, xml){
var root = xml.documentElement;
imgs = root.getElementsByTagName("img");
img = (Browser.Engine.trident)? imgs[num].text : imgs[num].textContent;
$("ajax").set("html", "OK - "+root.getElementsByTagName("img").length+" - "+img);
},
onFailure:function(){ $("ajax").set("html","ERROR"); }
}).send(null);
return img ;
}
function show_img(){
num = Math.round( (Math.random()*4) );
var imgpath = show(num);
$("box_show").setStyle("background-image", "url(imgs/"+imgpath+")");
}
show_img();
)};//END "domready"