Javascript到Coldfusion,使用javascript中的变量来查询CF [英] Javascript to Coldfusion, using variable in javascript to query in CF with

查看:264
本文介绍了Javascript到Coldfusion,使用javascript中的变量来查询CF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在我的javascript文件中使用字符串数组,将其传递给coldfusion页面,并使用数组中的元素作为参数, cfquery>?

Can I use a string array in my javascript file, pass it to a coldfusion page and use the elements in the array as parameters to search by in a < cfquery > ?

.js

$.get("submit.cfm",{arr: obj}).done( function(data) {
    alert('The returned data is: ' + data);
});

.cfm

<cfparam name="tempArr" default = "" >

<cfset array = ArrayNew(6)>

<cfloop from="1" to="6" index="i">
     <cfset ArrayAppend(array, tempArr[i])>
</cfloop>

代码不完整,但如何传递 obj (字符串数组)从javascript到我的coldfusion代码中的变量 tempArr

The code is incomplete, but how can I pass the values of obj (string array) from javascript to the variable tempArr in my coldfusion code

推荐答案

将数组转换为JSON(JavaScript对象符号),因此可以通过Ajax将其传递到服务器。那么您需要将JSON处理成服务器端数组结构。

You would need to convert your array to JSON (JavaScript Object Notation), so you can pass it to the server via Ajax. Then you would need to process the JSON into a server-side array structure.

有关详细信息,请参阅此文章...

See this article for more details...

将数组转换为JSON

这篇关于Javascript到Coldfusion,使用javascript中的变量来查询CF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆