process json returned from coldfusion cfc

Hi I have a form select bound to a cfc - i can see the json returned but its not displaying on my form - i have the code as below hope someone can help:

FORM

<script type="text/javascript">
// <!--
$(document).ready(function()
{
$("#CountriesList").change(function()
{
if($(this).val() != '')
{
$.ajax({
type: "POST",
url: "mycfc.cfc?method=GetCities&returnformat=json",
data: ({
CountryID: $(this).val()
}),
dataType: "xml",
success: function(xml)
{
$('#Cities option').remove();
$(xml).find('record').each(function()
{
$("#Cities").append('<option value="' + $(this).find('tape_width').text() + '">' + $(this).find('tape_width').text() + '<\/option>');
});
}
});
}
});

})

// -->
</script>

<cfsilent>
<cfinvoke component="mycfc" method="CountriesList" returnvariable="CountriesList"/>
</cfsilent>
 <cfoutput>
 <label for="CountriesList">Select Country:</label>
 <select name="CountriesList" id="CountriesList">
<option value="" selected="selected">...</option>
 <cfloop query="CountriesList"><option value="#BAND#">#CountriesList.BAND#</option></cfloop>
</select>
<label for="Cities">Select City:</label>
<select name="cities" id="Cities"><option value="">...</option></select>
</cfoutput>

The actual CFC is as below:

<cfcomponent>
<cffunction access="remote" name="CountriesList" output="false" returntype="query">
<cfquery name="SelectAllCountries" datasource="test">
 SELECT DISTINCT BAND
 FROM FABRICS
 WHERE TYPE='venetian'
 AND isACTIVE='true'
 ORDER BY BAND
</cfquery>
<cfreturn SelectAllCountries>
</cffunction>
<cffunction access="remote" name="GetCities" output="false" returntype="query">
<cfargument name="CountryID" required="yes" type="any" default="" />
<cfquery name="Cities" datasource="test">
 SELECT TAPE_WIDTH
 FROM tapes
 WHERE SLAT_WIDTH='#arguments.CountryID#'
</cfquery>
<cfreturn Cities>
</cffunction>
</cfcomponent>

Could someone point out where am going wrong please?

Thanks

Answers


I fixed a similar problem I was jhaving by adding queryformat as follows:

$.getJSON("getContacts.cfc?method=getContacts&returnformat=json&queryFormat=column

prior to this I was seeing the json being returned (through firebug) but it was not dipslaying...

Hope it helps


Need Your Help

How to return data and url as ajax result in asp.net mvc 2

jquery asp.net ajax asp.net-mvc

Hi how to send the url of viewdetails and the result calculated data to the ajax call.

dynamically filled forms with Jquery & Ajax

php javascript forms zend-framework dynamic

I have a bit of a problem achieving what I'm trying to do.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.