Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-31-2010, 08:31 AM   PM User | #1
amlsoft
New to the CF scene

 
Join Date: Dec 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
amlsoft is an unknown quantity at this point
(URGENT HELP) ResponseXML is null....

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......
amlsoft is offline   Reply With Quote
Old 01-01-2011, 01:22 AM   PM User | #2
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
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
oesxyl is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:44 AM.


Advertisement
Log in to turn off these ads.