I have a stored procedure that's returning a recordset of locations as XML for use on a Google map. The procedure works fine and returns a valid XML file.
On the client side, I have some JavaScript that's using the prototype library to connect to this procedure and return the XML. For some reason, nothing is making it through to the callback function in javascript. If I try showing request.responseText to view the data, there's nothing there.
Strange thing is, I can save the XML output from the procedure as a static file - then load the static file using the same JavaScript and everything works like a charm. I know the data returned from the procedure is correct. I know the JavaScript is processing it correctly. I'm not sure where it's going wrong. I've experimented with MIME types, etc. but nothing's worked.
CF Code:
<cfstoredproc procedure="usp_get_all_locations" datasource="#application.datasource_wc#">
<cfprocresult name=RS>
</cfstoredproc>
<cfprocessingdirective suppresswhitespace="Yes">
<cfcontent type="text/xml">
<cfoutput><?xml version="1.0" encoding="utf-8" ?>
<locations>
<cfloop query="RS">
<camp>
<ID>#RS.campID#</ID>
<Name>#XMLFormat(RS.campname)#</Name>
<Lgt>#RS.camplongitude#</Lgt>
<Lat>#RS.camplatitude#</Lat>
</camp>
</cfloop>
</locations>
</cfoutput>
</cfprocessingdirective>
JS Code:
var url = 'getFunctions.cfm';
var request = new Ajax.Request(url,{method:'get',parameters:params,onSuccess:loadMarkers,onFailure:showError});
function loadMarkers(request){
var xml = request.responseXML;
var camps = xml.getElementsByTagName("camp");
alert(camps.length);
}
In this example, if I keep the url as the .cfm file, the loadMarkers function returns "0" as the length of the camps array. If I change the url variable to the resulting XML output, it returns "80" as the length.
I'm at a loss.
CetusMOD
Community Support Moderator