嗨,我有一个绑定到 cfc 的表单选择 - 我可以看到返回的 json,但它没有显示在我的表单上 - 我有如下代码,希望有人能提供帮助:
形式
<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>
实际的 CFC 如下:
<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>
有人可以指出哪里出错了吗?
谢谢