我有一个带有多个下拉列表的cfm页面(有些是cfselect)和动态生成的复选框列表相互依赖。我正在使用JQuery向cfc函数提交数据并显示数据。
我收到错误“GetBillsArr函数的PLANENROLLDATE_ID参数是必需的,但未传入。 错误发生在第-1行。 “
在控制台中,planenrolldate_id看起来像数组。 从控制台:
fM 9
fY 2014
method GetBillsArr
planenrolldate_id[] 564
planenrolldate_id[] 561
sponsor_id 59
tM 9
tY 2014
这是多个已检查的planenrolldate_id在控制台中查找的方式
["564", "559", "524", "517", "459", "438", "402", "390"]
下面是jquery函数:
function populateBills(){
var plID = $('#planenrolldate_id').val();
var sID = $('#sponsor_id').val();
var pID = $('#plan_id').val();
var fromMonth = $('#from_month').val();
var fromYear = $('#from_year').val();
var toMonth = $('#to_month').val();
var toYear = $('#to_year').val();
$.ajax({
type:"POST",
dataType: "json",
url:"../components/billing/custompremstat.cfc?method=GetBillsArr",
data: {
sponsor_id: sID,
planenrolldate_id: plID,
fM: fromMonth,
fY: fromYear,
tM: toMonth,
tY: toYear
},
success:
function(data){
$.each(data, function(index, item) {
addBillsCheckboxes(item.bill_id,item.bill_period);
});
},
error:
function(){
alert("An error has occurred while fetching bills");
}
});
}
这是冷酷的功能cfc part:
<cffunction name="GetBillsArr" access="remote" returnFormat="json" returnType="array">
<cfargument name="sponsor_id" type="any" required="true">
<cfargument name="planenrolldate_id" type="any" required="true">
<cfargument name="fM" type="numeric" required="true">
<cfargument name="fY" type="numeric" required="true">
<cfargument name="tM" type="numeric" required="true">
<cfargument name="tY" type="numeric" required="true">
<cfset var result=ArrayNew(1)>
<cfif ARGUMENTS.planenrolldate_id EQ "" OR ARGUMENTS.sponsor_id EQ "">
<cfset LstBills = QueryNew("bill_id, bill_period", "Integer, Varchar")>
<cfelse>
<cfquery name="LstBills" ...>
SELECT bill_id,
(Convert(varchar(10),billing_start_date,103) + ' - ' + Convert(varchar(10),billing_end_date,103)) + ' [' + Convert(varchar(6),plan_id) + ']' AS bill_period
FROM ...
</cfquery>
</cfif>
<cfloop query="LstBills">
<cfset returnStruct = StructNew()>
<cfset returnStruct["bill_id"]= bill_id>
<cfset returnStruct["bill_period"] = bill_period>
<cfset ArrayAppend(result,returnStruct) />
</cfloop>
<cfreturn result>
</cffunction>
这是cfm文件的一部分
<cfselect name="plan_id" bind="url:../components/billing/custompremstatus.cfc?method=GetPlans&langpref_id=#REQUEST.SESS.langpref_id#&sponsor_id={sponsor_id.value}&user_sup_list=0&returnFormat=json" display="name" value="plan_id" multiple="yes" bindonload="false" />
<cfselect name="planenrolldate_id" size="5" bind="url:../components/billing/custompremstatus.cfc?method=GetPlanEnrollments&sponsor_id={sponsor_id.value}&plan_id={plan_id.value}&returnFormat=json" display="enroll_period" value="planenrolldate_id" multiple="yes" bindonload="false" />
<em>FROM</em>
<select name="from_month" id="from_month">
<option value="0">Select Month</option>
<cfloop from="1" to="12" index="i">
<option value="<cfoutput>#i#</cfoutput>" <cfif Month(Now()) Eq i>selected</cfif>><cfoutput>#MonthAsString(i)#</cfoutput></option>
</cfloop>
</select>
/
<select name="from_year" id="from_year">
<option value="0">Select Year</option>
<cfset VARIABLES.iYearFrom = Year(Now()) - 10>
<cfset VARIABLES.iYearTo = Year(Now()) + 10>
<cfloop from="#VARIABLES.iYearFrom#" to="#VARIABLES.iYearTo#" index="i">
<option value="<cfoutput>#i#</cfoutput>" <cfif Year(Now()) Eq i>selected</cfif>><cfoutput>#i#</cfoutput></option>
</cfloop>
</select>
<div id="billid"></div>
================== UPDATE ============================ ======
这是由cfselect
生成的HTML<tr>
<td width="100">Plans:</td>
<td width="400">
<select name="plan_id" id="plan_id" multiple="multiple" size="5" >
</select>
</tr>
<tr>
<td width="100">Enrollment Periods:</td>
<td width="400">
<select name="planenrolldate_id" id="planenrolldate_id" multiple="multiple" size="5" >
</select>
</tr>