In IE it looks good, but not in Firefox.
Every time I call the info1() or info2() the "Loading..." show up and the content, is placed in the <div id="a"></div>.
This works in both browsers but with a different way.
In IE the previous content in the div is disappeared (this is what I want) and the new one, according to my choice, comes up.
In Firefox the previous content doesn't disappear. It stays on the page and the new one appears below that, and so on....
What's the problem in my code?
I have the folowing code:
<script language="javascript">
var httpRequest;
// for IE
if (window.ActiveXObject)
{
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
// for other browsers
else if (window.XMLHttpRequest)
{
httpRequest = new XMLHttpRequest();
}
function info1(url)
{
httpRequest.open('get',url, true);
httpRequest.onreadystatechange = parseInfo;
httpRequest.send(null);
}
function info2()
{
val = document.populate.hidden.value;
val2 = document.populate.country.options[document.populate.country.selectedIndex].value;
val3 = document.populate.job.options[document.populate.job.selectedIndex].value;
httpRequest.open('get','index.php?id=24&action='+v al+'&country='+val2+'&job=' +val3, true);
httpRequest.onreadystatechange = parseInfo;
httpRequest.send(null);
}
function parseInfo()
{
if(httpRequest.readyState == 1)
{
document.getElementById('a').innerHTML='Loading... ';
}
if (httpRequest.readyState == 4)
{
if(httpRequest.status == 200)
{
var answer = httpRequest.responseText;
document.getElementById('a').innerHTML = answer;
}
else
{
alert("Error loading page\n"+ httpRequest.status +":"+ httpRequest.statusText);
}
}
}
</script>
Any help is appreciated.
Georgia