Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    (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......

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    ask one of the moderators to move the thread in this forum http://www.codingforums.com/java-jsp/ 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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •