my js code.
$.ajax({
type: "POST",
url: "dgrid.cfc",
data: {
method: "getCountry"
},
dataType: "xml",
success: function(xmlData) {
$(xmlData).find("Results_Temp").each(function() {
$("#result").html(this.getAttribute("COUNTRY"));
});
},
error: function(x,y,z) {
console.log(x);
console.log(y);
console.log(z);
}
});
my cfc code:
<cfcomponent>
<cfsetting showdebugoutput="no">
<cffunction name="getCountry" access="remote" returntype="xml">
<cfquery datasource="fbrtest" name="getCountry2">
SELECT * FROM COUNTRY2
</cfquery>
<cfset objResults = XmlNew()>
<cfset objResults.xmlRoot = XmlElemNew(objResults,"info")>
<cfoutput query="getCountry2">
<cfset newAttribute = XmlElemNew(objResults,"Results_Temp")>
<cfset dfields = StructNew()>
<cfset StructInsert(dfields, "COUNTRY", COUNTRY)>
<cfset newAttribute.XmlAttributes = dfields>
<cfset objResults.info.XmlChildren[ArrayLen(objResults.info.XmlChildren)+1] = newAttribute>
</cfoutput>
<cfreturn objResults>
</cffunction>
</cfcomponent>
my success function does not trigger after the ajax call. does someone know what could be the problem?