jQuery可以很好地将数组分开发送,
numSeqCertidao[] = 'val1', numSeqCertidao[] = 'val2'...但是ColdFusion不能很好地处理此问题,因此不接受并将其重建为数组。
您的Javascript并非以JSON格式 发送
数据,dataType选项用于响应数据的格式。出于您的需要,我建议您
numSeqCertidao以列表形式发送,为CFC方法的参数提供一个字符串类型,其余部分保持原样,应该可以正常工作。
稍作修改的代码:
function removeCertidao(){ var allVals = []; $("input[id='certidao']:checked").each(function() { allVals.push($(this).val()); }); if (allVals.length == 0) { alert('É necessário escolher ao menos uma certidão.'); return false; } else { alert(allVals); } $.ajax({ type: "post", url: "../../CFC/CRC.cfc", data: { method: "removeCertidaoCRC", numSeqCertidao: allVals.join(), }, dataType: "json", success: function(){ alert('YES'); }, error: function(){ alert('NO'); } }); }<cffunction access="remote" name="removeCertidaoCRC" returntype="boolean"> <cfargument name="numSeqCertidao" type="string" required="true"><cftry> <cftransaction> <cfquery datasource="portalCompras"> UPDATE CRC_CERTIDAO CCSET CC.ncdcrcstatus = 0 WHERe CC.NCDCRCCERTIDAO in <cfqueryparam value="#numSeqCertidao#" cfsqltype="cf_sql_integer" list="yes"> </cfquery> </cftransaction> <cftransaction action="commit" /> <cfreturn 0> <cfcatch type="any"> <cftransaction action="rollback" /> <cfreturn #cfcatch.message#> </cfcatch></cftry></cffunction>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)