AJAX problem in Internet Exporer
Hi all.
I have a button on a page that uses AJAX to send a request off to my application server. The application server executes some functionality and then returns a String back to the client. The client then displays this String in an alert box. When I use Mozilla Firefox 1.5 the functionality works fine. It also works no matter how many times I click the button.
However, when I use Internet Explorer 6.0, I run into problems. The first time I click the button, the application server is called and the response is displayed on screen. The second and any subsequent times I click the button the response is displayed on the screen but the application server has not been called. The only way I can get the button to contact the applciation server is to close the window and open a new one. I am lost for ideas on how to overcome this problem.
Javascript is as follows:
<script type="text/javascript">
var xmlhttp
function generateTif(url)
{
xmlhttp=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest()
}
// code for IE
elseif (window.ActiveXObject)
{
xmlHttp =new ActiveXObject('Microsoft.XMLHTTP')
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_Change
xmlhttp.open("GET",url,true)
xmlhttp.send(null)
}
else
{
alert("Your browser does not support XMLHTTP.")
}
}
function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
{
// if "OK"
if (xmlhttp.status==200)
{
// OK response
alert(xmlhttp.responseText);
}
else
{
alert("Problem retrieving XML data")
}
}
}
</script>
The javascript is launched from the following line in the page:
<input type="button" name="genTif" value="Generate TIF" onclick="generateTif('GenerateTif.do');">
Does anyone have any ideas on the problem?
Cheers, Kenny

