hi i have web page which uses ajax to retrieving data from another pages and while doing that i want to show a loading gif in the page so i\'ve create a div with my gif on i
Use display instead of visibility. display: none for invisible and no setting for visible.
function loadpage (page_request, containerid)
{
var loading = document.getElementById ( "loading" ) ;
// when connecting to server
if ( page_request.readyState == 1 )
loading.style.visibility = "visible" ;
// when loaded successfully
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
{
document.getElementById(containerid).innerHTML=page_request.responseText ;
loading.style.visibility = "hidden" ;
}
}
If you just want to display it when you get a response add this to your loadpage()
function loadpage(page_request, containerid){
if (page_request.readyState == 4 && page_request.status==200) {
var container = document.getElementById(containerid);
container.innerHTML=page_request.responseText;
container.style.visibility = 'visible';
// or
container.style.display = 'block';
}
but this depend entirely on how you hid the div in the first place