Reputation: 956
I'm trying to test calling methods in a ColdFusion Application.cfc file using Ajax. As far as I can tell the following should work but I keep getting the following error returned:
"Invalid request of Application.cfm, Application.cfc, or OnRequestEnd.cfm file".
I am using ColdFusion 11.
The following is my Ajax call and the relevant method in the CFC.
$.ajax({
async: false,
type: 'GET',
cache: false,
url: 'Application.cfc?method=letsTestThis',
success: function(response){
alert(response);
},
error: function(xhr, status, error){
alert(error);
}
});
<cfcomponent displayname="NAME" output="true" hint="Handle the application.">
... some more functions etc. ...
<cffunction name="letsTestThis" access="public" returntype="string" output="false" description="">
<cfreturn "It worked!">
</cffunction>
</cfcomponent>
What am I doing wrong?
Upvotes: 0
Views: 212
Reputation: 3953
You can't directly access Application.cfc from the URL. Your ajax call needs to hit another CFC. Also, access type of the method will need to be public.
Upvotes: 4