6

I am trying to figure out how to get a node's value in Javascript. I've read a few tutorials but the examples they use are all much more complex than what I'm doing..

Here's my Javascript

        if(xmlhttpp.readyState==4 && xmlhttpp.status==200){
            document.getElementById("ajax_status").innerHTML=xmlhttpp.responseXML.getElementsByTagName('status').nodeValue;
        }

And the XML is..

<?xml version='1.0' encoding='UTF-8'?>
<resp><fname>Kyla</fname>
<lname>Bonds</lname>
<addr>6916 S Elizabeth Street</addr>
<city>Chicago</city>
<street>IL</street>
<zip>60636</zip>
<phone></phone>
<email>[email protected]</email>
<status>Found user</status></resp>

How can I get "Found User" from this?

1
  • Just a tiny point and not an answer to your question but the object would usually be referred to as xmlhttp rather than xmlhttpp. Commented Jan 23, 2014 at 20:06

1 Answer 1

8

Try

xmlhttpp.responseXML.getElementsByTagName('status')[0].firstChild.nodeValue
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.