TypeError: responseXml is null

StrongSoul

Grünschnabel
Hallo,

ich habe heute angefangen meine Regestrierung mit einer Ajax Validierung zu versehen.

leider bekomme ich dabei immer folgende Fehlermeldung:
TypeError: responseXml is null

Ich habe mich schon durch einige Foren durchgelesen aber bisher kam ich einfach nicht drauf was ich falsch gemacht habe.

Hier mal das JavaScript
Code:
function epos_validate(inputValue, fieldID){//Validiert Formularfeld
		if (xmlHttp){
			if (fieldID){
				inputValue = encodeURIComponent(inputValue);
				fieldID = encodeURIComponent(fieldID);
				cache.push("inputValue=" + inputValue + "&fieldID=" + fieldID);
			}
			try{
				if ((xmlHttp.readyState == 4 || xmlHttp.readyState == 0) && cache.length > 0){
					var cacheEntery = cache.shift();
					xmlHttp.open("POST", serverAddress, true);
					xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					xmlHttp.onreadystatechange = epos_handleRequestStateChange;
					xmlHttp.send(cacheEntery);
				}
			}
			catch (e){
				epos_displayError("85 " + e.toString());
			}
		}
	}
	
	function epos_handleRequestStateChange(){	//Behandlung der Http Antwort
		if (xmlHttp.readyState == 4){
			if (xmlHttp.status == 200){
				
				try{
					epos_readResponse();
				}
				catch (e) {
					epos_displayError("99 " + e.toString());
				}
			}else{
				epos_displayError("102 " + xmlHttp.statusText);
			}
		}
	}
	
	function epos_readResponse(){				//liest die Antwort vom Server
		var response = xmlHttp.responseText;
		
		if (response.indexOf("ERRNO") >= 0 || response.indexOf("error:") >= 0 || response.length == 0) throw(response.legth == 0 ? "Server-Fehler" : response);
		
		responseXml = xmlHttp.responseXML
		
		
		xmlDoc = responseXml.documentElement;
		result = xmlDoc.getElementsByTagName("result")[0].firstChild.data;
		fieldID = xmlDoc.getElementsByTagName("fieldid")[0].firstChild.data;
		message = document.getElementById(fieldID + "Failed");
		message.className = (result == "0") ? "error" : "hidden";
		setTimeout ("epos_validate()", 500);
	}

Und hier der PHP Code, indem das XML gebildet wird:

PHP:
	$response = 
		'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'.
			'<response>'.
				'<result>'.
					$validator->ValidateAJAX($_POST[inputValue], $_POST[fieldID]).
				'</result>'.
				'<fieldid>'.
					$_POST['fieldID'].
				'</fieldid>'.
			'</response>';
			
	if(ob_get_length()) ob_clean;
	header("Content-Type: text/xml; charset=utf-8");
	echo $response;

Jemand eine Idee warum das nicht Funktioniert?

Vielen Dank im vorraus und schönen Samstag noch
Soul

Edit:

Hab den Fehler gefunden. Hatte ein paar Syntaxfehler im PHP code gemacht -.-*
 
Zuletzt bearbeitet:
Zurück