Coldfusion-如何存储$.get()中的变量(Javascript)?
我在.js文件中有一个字符串数组,我正在使用$.get调用.cfm页面以最终执行查询,但我想知道如何在.cfm文件中存储使用$.get发送的数据 .js submit.cfm ?。我想使用Coldfusion-如何存储$.get()中的变量(Javascript)?,javascript,coldfusion,coldfusion-10,Javascript,Coldfusion,Coldfusion 10,我在.js文件中有一个字符串数组,我正在使用$.get调用.cfm页面以最终执行查询,但我想知道如何在.cfm文件中存储使用$.get发送的数据 .js submit.cfm ?。我想使用、还是有更好的替代方案 submit.cfm的目标最终是做一些类似的事情: <cfquery name="sample" datasource="database_live"> SELECT temp1[1], temp1[2], etc.... FROM table </cf
<cfquery name="sample" datasource="database_live">
SELECT temp1[1], temp1[2], etc....
FROM table
</cfquery>
有点混乱,因为您正在命名数组变量obj,但由于它实际上是一个数组。。。看起来数组只是一个列名数组,所以您可以简单地执行此操作 而不是:
<cfparam name="temp1" default="">
<cfset tempArr = ArrayNew(6)>
<cfquery name="sample" datasource="database_live">
SELECT temp1[1], temp1[2], etc....
FROM table
</cfquery>
只需使用:
<cfset tempArr = DeserializeJSON(URL.data) />
<cfquery name="sample" datasource="database_live">
SELECT tempArr[1], tempArr[2], etc....
FROM table
</cfquery>
如果希望根据数组中的项数动态查询,则:
<cfset tempArr = DeserializeJSON(URL.data) />
<cfset selectList = "" />
<cfloop array=#tempArr# index="i">
<cfset selectList = listappend(selectList,i) />
</cfloop>
<cfquery name="sample" datasource="database_live">
SELECT
<cfoutput>#selectList#</cfoutput>
FROM table
</cfquery>
有很多例子。。。搜索Ben NadelSo对页面的请求最终看起来像submit.cfm?arr=foo,bar,fubar?我会用什么?
<cfset tempArr = DeserializeJSON(URL.data) />
<cfquery name="sample" datasource="database_live">
SELECT tempArr[1], tempArr[2], etc....
FROM table
</cfquery>
<cfset tempArr = DeserializeJSON(URL.data) />
<cfset selectList = "" />
<cfloop array=#tempArr# index="i">
<cfset selectList = listappend(selectList,i) />
</cfloop>
<cfquery name="sample" datasource="database_live">
SELECT
<cfoutput>#selectList#</cfoutput>
FROM table
</cfquery>