Forum Moderators: open
This should be really easy to fix, but I've been staring at it all day.
function imageUpdater(action,image,expiration) {
var x_statement = "managecontent2.php?action=" + action + "&image_id=" + image + "&expiration=" + encodeURIComponent(expiration);
alert(x_statement);
xmlHttp = GetXmlHttpObject()
xmlHttp.open("GET",x_statement,true);
xmlHttp.send(null);
if (xmlHttp.readyState==4) {
if (xmlHttp.status == 200) {
var response = xmlHttp.responseText;
alert(response);
var theID = "image_" + image;
document.getElementById(theID).display = none;
}
}
}
The x_statement is indeed sent, and the php does receive it and process it. The php is supposed to send a "1" back to the javascript if everything went correctly but I can't get that simple result to alert. In fact, *nothing* alerts. Ever. Am I confusing a variable name somewhere?
Thanks for the help.
Glenn
function imageUpdater(action,image,expiration) {
var x_statement = "managecontent2.php?action=" + action + "&image_id=" + image + "&expiration=" + encodeURIComponent(expiration);
alert(x_statement);
xmlHttp = GetXmlHttpObject();
xmlHttp.onreadystatechange = function () { //assign a function to handle the response, before open and send...
//we can use the 'this' keyword within the onreadystatechange function,
//will refer to the xmlHttp object it's self
if (this.readyState == 4 && this.status == 200) {
var response = this.responseText;
alert(response);
var theID = "image_" + image;
//it's document.getElementById NOT document.getElementByID, case sensitive
document.getElementById(theID).style.display = 'none'; //style.display, not just .display,
//and 'none' is supposed to be string, unless you have a variable by that name somewheres...
}
};
xmlHttp.open("GET",x_statement,true);
xmlHttp.send(null);
}