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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    yet another ResponseXML problem

    I'm trying to fill out this DIV1 area (bottom of the HTML file) with simple name query form.

    Code:
     
    <FORM METHOD="GET">
    		<input type="text" name="searchemployee" id="searchemployee" />
    		<input type="button" value="Search" onClick="getEmployee ();" />
    </FORM>
    
    < DIV ID="div1">
    	<span id="employee_name"> </span><BR>
    	<span id="phone"> </span><BR>
    	<span id="position"> </span><BR>
    </DIV>
    My PHP file yields this XML, so I don't think it's where the problem is:
    Code:
    <searchemployee>
    	<employee_name>Jenny Smith</ employee_name>
    	<phone>867-5309</phone>
    	<position>Manager</ position>
    </searchemployee>
    And my JS is inside the head of the HTML file, as seen below. I've read many of the posts on this issue (ResponseXML, etc.) & followed all the advises on the function UPDATE part, even tried every other possible variations, to no result. I'm pretty sure, it's due to some minor dumb typo, but after 6 hours playing with this, I still can't find where the problem is. Help!!

    Code:
    var xmlhttp;
    function getEmployee(){
    	xmlhttp = getXMLHTTPRequest();
    	if (xmlhttp == null) {
    		alert("Browser does not support HTTP Request");
    		return;
    	}
    	var url = " getEmployee.php";
    	xmlhttp.open("GET", url, true);
    	xmlhttp.onreadystatechange = update;
    	xmlhttp.send(null);
    }
    
    function update(){
    	if (xmlhttp.readyState == 4) {
    		if (xmlhttp.status == 200) {
    			xmlDoc = xmlhttp.responseXML;
    			document.getElementById("employee_name").innerHTML = xmlDoc.getElementsByTagName("employee_name")[0];
    		}
    	}
    }
    
    
    function GetXmlHttpObject(){
    	if (window.XMLHttpRequest) {
    		return new XMLHttpRequest();
    	}
    	if (window.ActiveXObject) {
    		return new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	return null;
    }

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Code:
    var xmlhttp;
    function getEmployee(){
    	xmlhttp = getXMLHTTPRequest();
    
    //...
    function GetXmlHttpObject(){
    best regards

  • #3
    New to the CF scene
    Join Date
    May 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! And I found some other dumb mistakes after fixing that one.


  •  

    Posting Permissions

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