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

Sending/Receiving parameters

Guest
Dec 04, 2007 Dec 04, 2007

Copy link to clipboard

Copied

Using CF7... I need to send the values from two form fields via Ajax to the server without actually submitting the form, in a method very similar to a "lookup" cfc. The Ajax part is simple... but does anyone out there have documentation explaining the server side of the conversation in CF7? Could you provide me with a [book] title of a good reference or a URL with this information?

Thanks in advance.
TOPICS
Advanced techniques

Views

732

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
LEGEND ,
Dec 04, 2007 Dec 04, 2007

Copy link to clipboard

Copied

it is usually done via cfc. have you heard of ajaxCFC by Rob Gonda?
http://www.robgonda.com/blog/index.cfm/2007/1/15/AjaxCFC-for-jQuery-Alpha2-Release

it includes some simple examples. give it a try.

---
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

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
Guest
Dec 05, 2007 Dec 05, 2007

Copy link to clipboard

Copied

Thanks for the response, but I'm currently working at a federal agency - the FAA to be specific - and the odds are slim that ajaxCFC/jQuery will be available here any time soon.

In the meantime... I'm trying to bring Ajax functionality into this organization and it's working well - right up until a process needs to pass parameters to a [CF7] server-side script.

I can write a back-end program in C++ to pick up the parameters directly from the client, but it's unlikely that it would be maintained upon my departure. [I'm a consultant - not an employee.]

So... It would be preferable to construct a CF script in which the server-side script can read the needed parameters as part of a URL [e.g. abc.cfm?parm1=value1&parm2=value2...)] or from a JavaScript httpRequestObject.send() statement (e.g. httpRequestObject("parm1=value1|parm2=value2|...").

Thus far I haven't been able to locate any CF documentation to guide me in developing a script using either method... and Ajax has little value here if it can't be done.

... and that's why I thought to look for it here. Other suggestions?


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
LEGEND ,
Dec 05, 2007 Dec 05, 2007

Copy link to clipboard

Copied

To ColdFusion a request is a request and it does not care if it comes
from a browser or a javascript function inside the browser. I.E. If
you request abc.cfm?parm1=value1&parm2=value2, The abc.cfm template is
going to be run by ColdFusion. The URL variables will be provide to the
template in the URL scope. And ColdFusion will return whatever it has
been designed to return in the response to the request.

Even if you can't use any of the ColdFusion AJAX libraries, reading up
on their site and looking at the few files used by them should give you
a good idea of what you are trying to do. I beleive the CF side is
fairly trivial.

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
Guest
Dec 07, 2007 Dec 07, 2007

Copy link to clipboard

Copied

Actually, Ian, my problem is that CF is NOT reading Ajax-delivered URLs if parameters are attached in the manner you show. I receive a "can't find" message whenever I try sending a URL in that form.

It finds "abc.cfm", but not "abc.cfm?p1=v1&p2=v2".

.. and that's one reason I'm attempting to send parameters via other routes - most notably via httpRequest.send(). My preference would to send the parameters as a small xml file that would be parsed in "abc.cfm" and then - based upon the xml values - generate a 2nd XML page to be downloaded/parsed on the client.

A second reason is security: I can encode/decode the contents of the xml [parameter] file as well as the server response.

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
Explorer ,
Dec 07, 2007 Dec 07, 2007

Copy link to clipboard

Copied

Have you checked your web server logs to see exactly what the query string is? If the parameters are received by the web server then CF should have them in the URL scope.

Have you used Firebug to monitor the Ajax request? This will also show exactly what you are submitting. My guess is that your javascript is not building the request properly.

What Ian says is very true. Cold Fusion does not know what submits the request to it. It doesn't care. An Ajax request looks exactly the same to CF as a normal request submitted via the browser.

Once you get the parameter issue resolved, then the server-side code is totally up to you. It's just plain 'ol CFML and you can use a cfc or cfm, it doesn't matter. It's up to you what is returned to the browser. XML, JSON, plain text, or html.
I don't use ajaxCFC, but it is popular. I'm not sure why you can't use it, as it is nothing more then CF code. If you can't use that then I'm guessing that you can't use any third party custom tags, udfs, cfc's etc. Bummer!

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
Guest
Dec 07, 2007 Dec 07, 2007

Copy link to clipboard

Copied

If I'm reading it correctly, forget about AJAX etc for a sec. Here we're talking about HTML FORM or CFFORM for that matter, what's your form Method? Probably, "POST", and if you use this method, any URL parameters/values pairs would not recognized while the Method of "GET" will (according to W3C standard...).

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
Guest
Jan 04, 2008 Jan 04, 2008

Copy link to clipboard

Copied

LATEST
[Actually... although POST and GET operate differently you can send information using the XmlHttpRequest.send() method even if you've specified GET to the request object. Also: The form is never actually submitted; the ACTION parameter is set to an inactive JavaScript function]

But I did solve the problem... and I'm posting it here in case someone else runs into the same problem:

Passing URL parameters via Ajax as Ian Skinner indicated. They work. The problem that I encountered turned out to be maximum array sizes. That application loads a veritable TON of information [26 CF-generated XML files and still growing!]; MSIE and Gecko both support Ajax and XML, yet both handle XML as if it's an array.

I was getting an unreported "Stack Overflow" error from Firefox. Since Firefox has the better debugging system (especially with the Firebug add-on), I hadn't even tried the application in MSIE. Once I finally did so, MSIE reported the problem.

The solution was to reduce the volume of data being loaded by separating the data into several different [smaller] arrays rather than a few larger ones. Once that happened, CF was "magically" able to read a standard URL [using GET] in the standard URL?parm1=value1&parm2=value2... format.

Thanks to all of you for your suggestions - and especially to Ian Skinner whose advice got me to look in other directions.

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