brihol44
asked on
Coldfusion Ajax function question
I'm using <cffunctions in regular .cfm pages (not .cfc). I've followed this code pattern from a couple of other developers and I know it's probably not standard practice but I find it convenient and easier to work with sometimes. So, in a ajax call is it still possible to call functions or methods with a .cfm extension file? I haven't been able to do so yet. My code below is what I've been working with.
$.ajax({
type: "POST",
url: "myfunctions.cfm?method=myfunctionname",
data: "name=Tom",
cache: false,
success: function() {
alert("yes");
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
})
<cffunction name="deleteName"
access="public"
output="false"
returntype="void"
hint="delete name from users"
>
<cfargument name="name"
required="true"
default=""
type="string"
hint="name">
<cfquery datasource="#request.dsn#" username="#request.dsnUsername#" password="#request.dsnPassword#">
DELETE
FROM users
WHERE name = '#arguments.name#'
</cfquery>
</cffunction>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can always open a page and if there's some code behind reading passed parameters run a function so the answer is yes, that just mean you're not calling expressively the function
ASKER
ok, I tried that but I do have several functions on that page. It's not just the one cffunction I included in my example. I guess I didn't know how to run my example with it knowing what function to actually use.
All the function inside the page need to worry about if the << method >> parameter function is specified in the URL (query string) then DON'T run.
Doable but so bad, no?
Doable but so bad, no?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
All good stuff and the feedback I was looking for. Thank you!
ASKER