• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Coldfusion code to handle Ajax request (posted variables)

Contributor ,
Apr 21, 2017 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

778

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
community guidelines
Guide ,
Apr 21, 2017 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.

Votes

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
community guidelines
Advocate ,
Apr 24, 2017 Apr 24, 2017

Copy link to clipboard

Copied

LATEST

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.

Votes

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
community guidelines
Resources
Documentation