0

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>

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

1

1 Answer 1

1

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...

Convert array to JSON

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.