I am trying to call an AJAX function to display a block of text in a div every time the button is pressed. The problem is that the function will only run once – if the user clicks to cancel from inside the box, the display function wont run again.
Here are the two functions:
function block(field){
var ajaxRequest; // The variable that makes Ajax possible!
try{
ajaxRequest = new XMLHttpRequest();
} catch (e){
try{
ajaxRequest = new ActiveXObject(“Msxml2.XMLHTTP”);
} catch (e) {
try{
ajaxRequest = new ActiveXObject(“Microsoft.XMLHTTP”);
} catch (e){
alert(“Your browser broke!”);
return false;
}
}
}
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
document.getElementById(field).innerHTML = ajaxRequest.responseText;
}
}
block=”block.php?block=”+field;
ajaxRequest.open(“GET”, block, true);
ajaxRequest.send(null);
}
function blank(field) {
document.getElementById(field).innerHTML = “”;
}
Any help would be greatly appreciated. Thanks