Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AJAX loading image

Status
Not open for further replies.

snowboardr

Programmer
Joined
Feb 22, 2002
Messages
1,401
Location
PH
Does anyone know how to show a loading image when you are loading a page w/ ajax.

Thanks

ps. There isnt a ajax forum here, from what i could find.

Do you got a million? www.gotamillion.com/?r=T

 
Surely you would simply place an image element on the page, and hide it when the callback comes through?

Or did you want to do something a bit different to that?

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
i tried that before, and it didnt work don't mind the mess this is my first ajax project...

layer1 contains the animated image but it doesn't display do you see any problems w/ this?

Code:
var xmlHttp

function SaveCollapse(intCall,SaveThis,queryid)
{ 
var url="ajax_save.asp?call=" + intCall + "&save=" + SaveThis + "&id=" + queryid
xmlHttp=createRequestObject()
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 


var LoadHTMLHttp = null;
function LoadHtml(iCall,sSaveThis,intId,sCat2Name) {
	document.getElementById('Layer1').style.display="";
    LoadHTMLHttp = createRequestObject();
    var url="ajax_display.asp?call=" + iCall + "&save=" + sSaveThis + "&id=" + intId + "&cat2name=" + sCat2Name
    LoadHTMLHttp.open('GET', url, true);
    LoadHTMLHttp.onreadystatechange = getLoadHTMLHttpResponse;
    LoadHTMLHttp.send('');
}

function getLoadHTMLHttpResponse() {
    if (LoadHTMLHttp != null)
        if (LoadHTMLHttp.readyState == 4)
            if (LoadHTMLHttp.status == 200)
                document.getElementById('viewsubtopic').innerHTML = LoadHTMLHttp.responseText;
				document.getElementById('Layer1').style.display="none";
}

// topics.asp // loading Sub-Topics
var LoadHTML2Http = null;
function LoadHtml2(iCall,sSaveThis,intId,sCat2Name) {
	document.getElementById('Layer1').style.display="";
    LoadHTML2Http = createRequestObject();
    var url="ajax_display2.asp?call=" + iCall + "&save=" + sSaveThis + "&id=" + intId + "&cat2name=" + sCat2Name
    LoadHTML2Http.open('GET', url, true);
    LoadHTML2Http.onreadystatechange = getLoadHTML2HttpResponse;
    LoadHTML2Http.send('');
}

function getLoadHTML2HttpResponse() {
    if (LoadHTML2Http != null)
        if (LoadHTML2Http.readyState == 4)
            if (LoadHTML2Http.status == 200)
                document.getElementById('viewsubtopic').innerHTML = LoadHTML2Http.responseText;
				document.getElementById('Layer1').style.display="none";
}

var intRow = null;
var LoadPOSTHTMLHttp = null;
function LoadPOSTHtml(cat1,_intRow,intPaging) {
    intRow = _intRow;
	 document.getElementById('Layer1').style.display="";
	  document.getElementById('Layer2').style.display="";
    LoadPOSTHTMLHttp = createRequestObject();
    var url2="ajax_display.asp?call=4&cat1=" + cat1 + "&cat2=" + intRow + "&page=" + intPaging
    LoadPOSTHTMLHttp.open('GET', url2, true);
    LoadPOSTHTMLHttp.onreadystatechange = getLoadPOSTHTMLHttpResponse;
    LoadPOSTHTMLHttp.send('');
}

function getLoadPOSTHTMLHttpResponse() {
    if (LoadPOSTHTMLHttp != null)
        if (LoadPOSTHTMLHttp.readyState == 4)
            if (LoadPOSTHTMLHttp.status == 200)
                document.getElementById('viewpoststable'+intRow).innerHTML = LoadPOSTHTMLHttp.responseText;
				document.getElementById('Layer1').style.display="none";
				document.getElementById('Layer2').style.display="none";
				
}

function createRequestObject() {
    var ro;
    /*@cc_on
    @if (@_jscript_version >= 5)
        try {
            ro = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                ro = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                ro = false;
            }
        }
    @else
        ro = false;
    @end @*/
    if (!ro && typeof XMLHttpRequest != 'undefined') {
        try {
            ro = new XMLHttpRequest();
        } catch (e) {
            ro = false;
        }
    }
    return ro;
}

Do you got a million? www.gotamillion.com/?r=T

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top