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 1 of 1
  1. #1
    Regular Coder djh101's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    628
    Thanks
    51
    Thanked 67 Times in 67 Posts

    Retrieving data from responseXML

    RESOLVED: Didn't set the content type. Embarrassing.

    AJAX:
    Code:
    xmlhttp1.onreadystatechange=function(){
    	if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
    		var i;
    		var getvars = xmlhttp1.responseXML;
    		if(i = getvars.getElementsByTagName('error')[0]){
    			alert(i.childNodes[0].nodeValue);
    		} else {
    			if(i = getvars.getElementsByTagName('numcoms')[0]){
    				alert(i.childNodes[0].nodeValue);
    			}
    			if(i = getvars.getElementsByTagName('pageord')[0]){
    				alert(i.childNodes[0].nodeValue);
    			}
    		}
    	}
    }
    XML:
    Code:
    <?xml version="1.1" encoding="ISO-8859-15"?>
    <vars>
    <pageord>ASC</pageord>
    <numcoms>2</numcoms>
    </vars>
    If I use responseText, the XML page is displayed just fine, so nothing is wrong there. However, the alerts don't alert; alerting xmlhttp1.responseXML returns null; and simply alerting getvars.getElementsByTagName('pageord')[0].childNodes[0].nodeValue doesn't return anything.
    Last edited by djh101; 08-06-2011 at 08:09 AM.
    "Yeah science!"


 

Posting Permissions

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