KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a ColdFusion CFC function like this: <cffunction access="remote" name="getResults" returntype="struct" returnformat="JSON" output="no"> <cfargument name="q" required="true" type="array" /> ... </cffunction> How do I call this function from jQuery? Neither form of array encoding by jQuery will get ColdFusion to see the value as array. If you pass "q=a&q=b" (like with jQuery.ajaxSettings.traditional = true), the function will get the string "a,b", not an array. While splitting on comma may seem like a possibility, it will not work if one of the "q" values contains a comma. Also, ideally, the function on the server-side should not have to be aware of the problems of how to serialize the data over the wire, and should continue to take in an array. If you pass "q[]=a&q[]=b" (the jQuery default), it will not map over to the "q" parameter. If you try to change the name of the "q" parameter to "q[]", the CFC will error out due to an invalid parameter name.
Tags (comma-separated)
Save Edits
Cancel