garethhall Posted October 21, 2009 Share Posted October 21, 2009 Hello Guys I have page I am working on but my xml object is null? well it's null when I do an alert? Can you guys see something work? Javascript var xmlHttp function getMemDetail(){ xmlHttp=GetXmlHttpObject() if(xmlHttp==null){ alert("Browser does not support HTTP Request"); return; } var qstr; qstr = "memID="+document.getElementById('members').value; xmlHttp.onreadystatechange = returnDetails; xmlHttp.open("POST","ajax/getMemberDetails.php?",true); xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlHttp.send(qstr); } function returnDetails(){ if(xmlHttp.readyState==4 ){ //alert(xmlHttp.responseText); //xmlDoc = xmlHttp.responseXML; alert(xmlHttp.responseXML); //WHY IS THIS NULL document.getElementById("toName").innerHTML = xmlDoc.getElementsByTagName("memFirstName")[0].childNodes[0].nodeValue; } } function GetXmlHttpObject(){ var xmlHttp=null; try{ // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); }catch (e){ // Internet Explorer try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }catch (e){ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp;} PHP <?php include("../../includes/cmsConfig.php"); include("../../includes/sharedFunctions.php"); auth(); $sql = "SELECT * FROM members WHERE memID = ".checkVars($_POST['memID']); $rs = mysql_query($sql ,$admin); $rw = mysql_fetch_assoc($rs); echo '<?xml version="1.0" encoding="ISO-8859-1"?>'; echo '<member>'; echo '<memName>'.$rw['memName'].'</memName>'; echo '<memFirstName>'.$rw['memFirstName'].'</memFirstName>'; echo '<memLastName>'.$rw['memLastName'].'</memLastName>'; // echo '<memAddress>'..'</memAddress>'; echo '</member>'; ?> Link to comment https://forums.phpfreaks.com/topic/178441-cant-get-xml-data-to-javascript/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.