I want to return true if the responseText is nothing and return false if the responseText is something. These return statements must be at the end of the function checkFields()….I’ve tried a million things and couldn’t find any way to determine if the ajax request returned a value or not (at least I couldn’t determine this from the checkFields function, where I need to be able to determine it). Does anybody know a way to determine if the request returned anything from the checkFields function? Thanks for any help.
[code]
function checkfields() {
xmlHttp=GetXmlHttpObject();
if(xmlHttp==null) {
return false;
}
tinyMCE.triggerSave();
title = document.getElementById(“theTitle”).value;
post = document.getElementById(“thePost”).value;
attach = document.getElementById(“attach”).value;
var url = “http://localhost/panl/scripts/forum/newpost.php”;
var params = “title=”+title+”&post=”+post+”&attach=”+attach+”&ajax=true”;
xmlHttp.open(“POST”, url, true);
//Send the proper header information along with the request
xmlHttp.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);
xmlHttp.setRequestHeader(“Content-length”, params.length);
xmlHttp.setRequestHeader(“Connection”, “close”);
xmlHttp.onreadystatechange = stateChangedNewPost;
xmlHttp.send(params);
return false;
}
function stateChangedNewPost() {
thisElement = getThisElement();
if(xmlHttp.readyState==4) {
thisElement.innerHTML = xmlHttp.responseText;
}
}
function getThisElement() {
for (i=0;i<document.getElementsByTagName(“div”).length; i++) {
if(document.getElementsByTagName(“div”).item(i).className == “row”){
if(document.getElementsByTagName(“div”).item(i).title == “error”) {
return thisElement = document.getElementsByTagName(“div”).item(i);
}
}
}
}