The following code works in IE, but in Forefox (1.0.7 & 1.5) the
Asyncronous function (testA) works fine but the Synchronous one (testS)
does not. It just doesn't work & I get no errors.
Anybody have an idea why?
<script>
function testA () {
var element = document.getElementById('show1');
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.onreadystatechange = function() {
if (req.readyState == 4 && req.status == 200) {
element.innerHTML = req.responseText;
}
}
req.open("POST", 'response.php', true);
req.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
req.send(null)
}
function testS () {
var element = document.getElementById('show2');
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.onreadystatechange = function() {
if (req.readyState == 4 && req.status == 200) {
element.innerHTML = req.responseText;
}
}
req.open("POST", 'response.php', false);
req.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
req.send(null)
}
</script>
<span id="show1">show 1</span><br>
<span id="show2">show 2</span><br><br>
<input type="button" value="Test Async" onClick="testA();">
<input type="button" value="Test Sync" onClick="testS();">