...

View Full Version : (URGENT HELP) ResponseXML is null....



amlsoft
12-31-2010, 09:31 AM
Hi guys...
Im very new to JavaScript programming.. Im doing a JSP page form validation... I downloaded this code but every time my responseXML object getting null....

Im not using any external XMl file here to load data.... but still its not working for me....

My JS file.....

function validate(inputValue, fieldID){
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 cacheEntry = cache.shift();

xmlHttp.open("POST", serverAddress, true);
xmlHttp.setRequestHeader("Content-Type","text/xml; charset=utf-8");
xmlHttp.onreadystatechange = handleRequestStateChange
xmlHttp.send(cacheEntry);
}
}catch (e){
displayError(e.toString());
}
}
}

function handleRequestStateChange(){
if (xmlHttp.readyState == 4){
if (xmlHttp.status == 200){
try{
readResponse();
}catch(e){
displayError("HERE AT METHOD CALL >"+e.toString());
}
}else{
displayError(xmlHttp.statusText);
}
}
}

function readResponse(){
var response = xmlHttp.responseText;

if (response.indexOf("ERRNO") >= 0 || response.indexOf("error:") >= 0 || response.length == 0)
throw(response.length == 0 ? "Server error." : 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("validate();", 250);
}

function setFocus(){
document.getElementById("txtUsername").focus();
}

Thanks in advance......

oesxyl
01-01-2011, 02:22 AM
ask one of the moderators to move the thread in this forum http://www.codingforums.com/forumdisplay.php?f=54 you have bigger chances to get a answer there.
Also put your code between [code ] and [/code ] tags.( remove spaces)

best regards and happy new year



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum