
October 5th, 2006, 09:30 AM
|
 |
Resident DJ
|
|
Join Date: Feb 2001
Posts: 283
 
Time spent in forums: 1 Day 1 h 55 m 24 sec
Reputation Power: 9
|
|
Quote: | Originally Posted by oOo You have to use 'responseXML' instead of 'responseText'. I'm not sure how Prototype handles it, though. You may need to send an xml header with the request if you have problems receiving it. |
It doesn't handle it very well... You do have to send the header, but it does not help.
I'm having the same exact issue as the OP.
First the XML returned (submitting is no problem, reading is)
Code:
<?xml version="1.0" encoding="utf-8" ?>
<ajax-reponse>
<response type="object" id="VenueDetailsId">
<venue>
<venue-id>9521</venue-id>
<venue-name>Sneed's Feed & Seed (Formerly Chuck's)</venue-name>
</venue>
</response>
</ajax-reponse>
javascript Code:
Original
- javascript Code |
|
|
|
<script type="text/javascript"> function FormSubmit() { var someNodeList = $('FormId').getElementsByTagName('input'); var nodes = $A(someNodeList); var url = "/form.php"; var pars = "type=addvenue"; for(var i=0; i < nodes.length; i++) { if("button" != nodes[i].type) { pars += "&" + nodes[i].name + "=" + nodes[i].value; } } var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete: handlerFunc, onFailure: reportError }); } var handlerFunc = function(t) { try { var xmlDoc = t.responseXML.documentElement; // returns HTML Object or HTML Collection // and attempts to loop through return UNDEFINED or NULL } catch(e) { alert(e.message); } //Handle data. } </script>
Now, if I get out of using Prototype.js back to the w3schools example, it works just fine (but no more prototype, which is unfortunate because outside of this issue it works well and I've written some nice code to go along with it)
w3schools option - which works in comparison
But if I go back to the way a little more familiar (this is from w3schools.com) it works perfectly
Last edited by ajax : October 5th, 2006 at 09:33 AM.
|