|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Prototype : Returning XML
Hi,
I am attempting to use the prototype framework in an application. I am using it's Ajax functions and would like to know how I get the XML that is returned from the Ajax request call. Any documentation I've seen only talks about using the "originalRequest.responseText" as a way to get what was returned. Is there not a way to get some sort of XML object returned from it? My code is (if it helps): Code:
function getControlID(type) {
url = ssl + '/includes/ajax/getControlID.cfm';
pars = 'type=' + type;
myAjax = new Ajax.Request( url,
{ method: 'get',
parameters: pars,
onComplete: addControl });
}
function addControl(originalRequest) {
currentID = originalRequest.responseText;
alert(currentID);
}
So right now all I'm getting back as an example is: Code:
<?xml version="1.0" encoding="utf-8" ?> <ajax-response> <response type="object" id="controlDetails"> <control> <nextID>2</nextid> <type>text</type> </control> </response> </ajax-response> .. as plain text. |
|
#2
|
||||
|
||||
|
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.
|
|
#3
|
||||||
|
||||||
|
Quote:
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:
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. |
|
#4
|
||||
|
||||
|
I figured it out.
Using "text/xml" doesn't work This takes care of it: PHP Code:
|
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > Prototype : Returning XML |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|