I am calling a function with the following code:
var resultz = nsEditor.updateStringCall(debtID, column2Change, value2Change, 4, 10);
The function that is being called but doesn't return a value
updateStringCall: function(pdebtID, pcolumn2Change, pvalue2Change, pmin, pmax){
try {
var resultz2 = 0;
$.ajax({
type: "POST",
url: "Components/MintLibraries.cfc",
dataType: "json",
cache: false,
data: {
method: 'StringUpdate',
val2Change: pvalue2Change.trim(),
debtID: pdebtID,
column2Change: pcolumn2Change,
greaterThan: pmin,
lesserThan: pmax,
returnFormat: "json"
},
success: function(response) {
resultz2 = 1;
return resultz2;
}, //end done
error: function(jqXHR, textStatus, errorThrown){
resultz2 = 0;
return resultz2;
}); //end ajax call
} catch (e) {
resultz2 = 0;
return resultz2;
} //end trycatch
}, // end updateStringCall
This function uses the .ajax to call a coldfusion cfc method StringUpdate:
<cffunction name="StringUpdate" access="remote" output="false" returntype="any" >
<cfargument name="val2Change" type="string" required="true" />
<cfargument name="debtID" type="string" required="true" />
<cfargument name="column2Change" type="string" required="true" />
<cfargument name="greaterThan" type="numeric" required="false" />
<cfargument name="lesserThan" type="numeric" required="false" />
<cfset var debt2Pass = int(val(arguments.debtID)) />
<cfset var updQuery = "" />
<cfset var retValue = 0 />
<cfset var iVal = 0 /><cfset var valError = '' />
<cftry>
<cfquery name="updQuery" datasource="#application.datasource#" result="qResults" >
Update dmf set #arguments.column2Change# =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.val2Change#"/>
where DebtID =
<cfqueryparam cfsqltype="cf_sql_smallint" value="#arguments.debtID#"/>
</cfquery>
<cfset retValue = 1 />
<cfcatch type="Any" >
<cfset thrown = ThrowCFError(405,'debug', 'Error updating ' & arguments.DebtID,arguments.val2Change & ', ' & arguments.debtID & ',' & arguments.column2Change) />
<cfset retValue = 0 />
</cfcatch>
</cftry>
<cfreturn retValue />
</cffunction>
The query runs successfully but the js function doesn't return a value (it shows up as undefined). Even if it gets an error, I would think I have accounted enough for that to at least get a return value.
Ideas?