Highlighted

Coldfusion code to handle Ajax request (posted variables)

Participant ,
Apr 21, 2017

Copy link to clipboard

Copied

I have used ColdFusion for database interaction (in standard form-submit based apps). Right now I need to attempt something fancier. The plan is to use JQuery to do an Ajax post of variables to a server, and I'm hoping to use ColdFusion to handle these Ajax requests.  I have no experience with Ajax, but I'm hoping to learn. Can someone please refer me to some examples so I can figure out how to do this? Sorry to be such a newbie on the topic. I appreciate any help.

Views

643

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Coldfusion code to handle Ajax request (posted variables)

Participant ,
Apr 21, 2017

Copy link to clipboard

Copied

I have used ColdFusion for database interaction (in standard form-submit based apps). Right now I need to attempt something fancier. The plan is to use JQuery to do an Ajax post of variables to a server, and I'm hoping to use ColdFusion to handle these Ajax requests.  I have no experience with Ajax, but I'm hoping to learn. Can someone please refer me to some examples so I can figure out how to do this? Sorry to be such a newbie on the topic. I appreciate any help.

Views

644

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 21, 2017 0
Most Valuable Participant ,
Apr 21, 2017

Copy link to clipboard

Copied

I'd start with the jQuery docs for making AJAX requests.  While their examples likely reference PHP or other language for the server-side stuff, that can easily be done with ColdFusion instead.  You can use either a .cfm page to provide the response, but it's usually a little easier to do it via a component (.cfc) with a "remote" function (that way you can return only the JSON or XML data you want to and not any extraneous HTML "noise").  Here is some documentation on writing components, and there is a section about invoking methods (functions) from a URL or FORM (which is essentially what AJAX requests are doing).

There can be a lot more to it - security and authentication issues need to be considered - but that should get you started.

-Carl V.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 21, 2017 0
Advocate ,
Apr 24, 2017

Copy link to clipboard

Copied

Short answers: Yes. There are various ways to accomplish the task. I prefer not to use the CFC method as Carl referenced just because I like knowing and controlling every factor - I'm kind of OCD about stuff like this. The CFC method hides a lot of the lower level stuff but to me this makes it harder to diagnose if and when problems occur once your code has contact with the enemy, er, users.

Again as Carl mentioned, security and authentication must be considered. I go even further, security should be the core and everything else would be considered "features". But then again, I mostly deal with payments so I tend to be a little paranoid.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 24, 2017 1