I have an interesting problem. I Have a jquery ajax command to get data from a MySQL table (code to follow) When i then build my table values that should be yes are now true and
Hi All the comment Ageax was correct. Its a ColdFusion bug, I just added white space then trim the value later and it worked perfectly.
Thanks very much
You didn't mention which version of CF you're using, but ... there's one other option for queries in ColdFusion 2016+. Using the new query serialization settings in your Application.cfc will preserve the yes/no
values as strings AND convert the query into a jQuery compatible array of structures - automatically. Obviously being application level settings, they'll apply to all queries within the application.
serialization.serializeQueryAs = "struct" - Automatically serialize all queries in the application as an array of structures (instead of the weird format CF uses by default).
serialization.preserveCaseForQueryColumn = true - Preserve the case of query column names (instead of converting everything to upper case).
Application.cfc
component {
this.name = "Your_Application_Name_Here";
this.serialization.serializeQueryAs = "struct";
this.serialization.preserveCaseForQueryColumn = true;
}
DemoComponent.cfc
<cfcomponent>
<cffunction name="getData" access="remote" returntype="query">
<!--- DEMO query. Note, manual queries MUST include column data types --->
<cfset local.getItems = QueryNew("onceoff,exvat"
, "varchar,varchar"
, [{exvat : "yes",onceoff : "no"}]
)>
<cfreturn local.getItems>
</cffunction>
</cfcomponent>
Result
[{"onceoff":"no","exvat":"yes"}]