I am new to ColdFusion, currently using CFWheels Framework. I have a snippet that send a ajax request from the view using jquery post with two parameters name and time.
$(".building").on("blur", function() {
$.post("index.cfm/audit/building", { name: "John", time: "2pm" })
.done(function( data ) {
alert( "Data Loaded: " + data );
});
});
My controller action
<cffunction name="building">
<cfscript>
categories = model("buildings").findByKey(params.name);
test = params.name & params.time;
renderText(test);
</cfscript>
</cffunction>
My Model
<cfcomponent extends="Model">
<cffunction name="init">
<cfset table("buildings")>
<cfset hasMany("rooms")>
</cffunction>
</cfcomponent>
I wish to do a simple task as following
- check if any building by passed name exist in database
- if so then return the row in json format, like echo json_encode in php
- else create new record and redirect to another action with params
I am stuck on step 1, and its telling me
The value for cfqueryparam cannot be determined
What does this mean? Please help, also if anyone can also tell me how to render query data in json form for jquery post to read.