function output(http_request,layerName) { //Check to see if the XmlHttpRequests state is finished. if (http_request.readyState == 4) { //Set the contents of our span element to the result of the asyncronous call. if (http_request.status == 200) { document.getElementById(layerName).innerHTML = http_request.responseText; } else if((http_request.readyState == 1) ||(http_request.readyState == 2)){ document.getElementById(layerName).innerHTML = "loading...<img src=\"loading.gif\"/>"; } else { document.getElementById(layerName).innerHTML = "Sorry, currently unavailable"; } } } Code (markup): I am loading a file with a big image. I can see the image, but not the loading.gif and loading text <span id="test" onclick="makeRequest('bigimg.php','test')"> show biggie </span> Code (markup): Which readystate do i need to check to show the loading.gif????
ah this seems to work //Called every time our XmlHttpRequest objects state changes. function output(http_request,layerName) { //Check to see if the XmlHttpRequests state is finished. if((http_request.readyState == 1) ||(http_request.readyState == 2)){ document.getElementById(layerName).innerHTML = "<span align=\"center\">Loading<img src=\"loading.gif\"/></span>"; } else if (http_request.readyState == 4) { //Set the contents of our span element to the result of the asyncronous call. if (http_request.status == 200) { document.getElementById(layerName).innerHTML = http_request.responseText; } } else { document.getElementById(layerName).innerHTML = "Sorry, currently unavailable"; } } //} Code (markup):
@gibex, tx for the tip I am trying it out. Do you know how to pass a php-array in pars = array new Ajax.Updater('div-name', file, { method: 'post', parameters: pars}); Code (markup): Which other ajax libs do you recommend???
@ritadebock, I think amnezia means something in the line function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } Code (markup): and <body onload="MM_preloadImages('loadng.gif');" Code (markup): regards