I have function that makes call to .cfc pag. I'm passing method and parameter along with the page name. Here is my code:
function callFunction(name){
param = name;
location.href = 'myTest.cfc?method=getRecords&userName=' + param;
}
Here is my cffunction on cfc page:
<cfcomponent>
<cffunction name="getRecords" access="remote" returnformat="void">
<cfargument name="userName" type="string" required="yes">
<cfset myResult = "1">
<cftry>
<cfquery name="getResults" datasource="test">
//myQuery
</cfquery>
<cfcatch>
<cfoutput>#cfcatch#</cfoutput>
<cfset myResult="0">
</cfcatch>
</cftry>
<cfreturn myResult>
</cffunction>
</cfcomponent>
My code doesn't give me return variable after I make a call to my function. I'm not sure what I'm missing in my code. If anyone can help with this problem please let me know.
returnFormat="void". Void is for returnType. ThereturnFormatshould bejson,wddx,orplain. - LeeishgetRecords. Are you trying to send the user to a page? Show the records on the page? Send the user to a page based on the user name? In the code provided, your function does not make a call to the cfc page. - Leeishlocation.href. Do you have more code that would have this make more sense. If you want your javascript to know if that call results in a 1 or a 0, you have to call the page behind the scenes, AJAX. - Leeish