Jump to content

placing loading indicator


dev

Recommended Posts

hi i am facing problem placing a loding indicator which parsing a remote xml file with microsoft.xmldom. here is the code:var _dc=document;function load(){try{xmlDT=new ActiveXObject("Microsoft.XMLDOM");}catch(e){try{xmlDT=_dc.implementation.createDocument("","",null);}catch(e){alert(e.message);return;}}xmlDT.async=false;xmlDT.onreadystatechange=function(){if (xmlDT.readyState == 1){_dc.getElementById('contarea').innerHTML='Loading, please wait...';}else if(xmlDT.readyState == 4){_dc.getElementById('contarea').innerHTML='Loaded successfully!';return false;}else{_dc.getElementById('contarea').innerHTML="Data can not be retrieved at this moment!!";}}xmlDT.load('remote.xml');}------------this doesn't show a loading text which the request is in the process but when loaded fully it show the readystate ==4 text.please tell me where i am doing wrong and how can it be solved?with thanksdev

Link to comment
Share on other sites

Hmm... why don't you use the XMLHttpRequest object? I find it easier to use.

var _dc=document;function load(){	var xmlDT = window.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("MSXML2.XMLHTTP");	xmlDT.onreadystatechange=function(){		if (xmlDT.readyState < 4) _dc.getElementById('contarea').innerHTML='Loading, please wait...';		else {			if (this.status != 200) _dc.getElementById('contarea').innerHTML = "Data can not be retrieved at this moment!!";			else {				_dc.getElementById('contarea').innerHTML = 'Loaded successfully!';				return false;			}		}	}	xmlDT.open("GET", "remote.xml", false);	xmlDT.send(null);}

You can access the XML DOM with the .responseXML property.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...