This content has been marked as final. Show 7 replies
it is usually done via cfc. have you heard of ajaxCFC by Rob Gonda?
it includes some simple examples. give it a try.
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.]
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?
To ColdFusion a request is a request and it does not care if it comes
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
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.
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.
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!
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...).
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.