Copy link to clipboard
Copied
Or, is there a way to write data values to a database using javascript directly? I have a set of data, that is being collected and passed via javascript. So, my thought is to pass those data values from js to Coldfusion to write them back to the database. But, let me know if there is a better way to do that.
Thanks,
Ros
1 Correct answer
Prior to CF8 you would be using CFAjax or AjaxCFC or rolling your own.
http://www.indiankey.com/cfAjax/
http://www.robgonda.com/blog/projects/ajaxcfc/
Your on your own for rolling your own.
Copy link to clipboard
Copied
cf = server-side
these are 2 parallel worlds only connected by http request/response
path... unless you stay on that path, you will never reach the other
world...
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Copy link to clipboard
Copied
ColdFusion data to HTML.
<cfset myCFvar = "Say goodnight Gracie.">
<cfoutput>
<script type="text/javascript>
var myJSvar = #myCFvar#;
alert(myJSvar);
</script>
</cfoutput>
The <cfwddx...> tag with its' CFML2JS option makes it easier to convert
complex data structures from CF to JS forms.
To pass JavaScript data to ColdFusion you have to submit it in a
request. You can submit it as a get request in the URL, as a post
request with form controls or with an Asynchronous JavaScript request
with XMLHttpRequest commonly called 'AJAX'.
Copy link to clipboard
Copied
Thanks Ian,
Could you please give an example of the Asynchronous JavaScript request
with XMLHttpRequest commonly called 'AJAX'. This sounds like what I would need to do to pass the data values back to Cold fusions and then write them to the database.
Ros

Copy link to clipboard
Copied
http://livedocs.adobe.com/coldfusion/8/Tags_a-b_3.html
--
Adam
Copy link to clipboard
Copied
Great.. Thanks, Adam. I will check it out. -Ros
Copy link to clipboard
Copied
cfajaxproxy is great.. But it is only available on CF8.. We are running CF 7. So, how would you do it in that case?
thanks,
Ros
Copy link to clipboard
Copied
Prior to CF8 you would be using CFAjax or AjaxCFC or rolling your own.
http://www.indiankey.com/cfAjax/
http://www.robgonda.com/blog/projects/ajaxcfc/
Your on your own for rolling your own.
Copy link to clipboard
Copied
Hi Ian,
One more question for you regarding CFAjax.. Can 2 parameters be passed to the DWREngine._execute?
All the examples that I have found only have one parameter. I figure the back up option would be to concat the variables into one string to pass them to the engine and separate them in the CFfunction, but I did not want to go down that path if there is a better way.
Thanks,
Ros
Copy link to clipboard
Copied
OK, it all works great! 🙂
For those that may be looking for this answer, multiple parameters can be passed to the DWREngine._execute command by a comma separator.
DWREngine._execute(_cfscriptLocation, null, doQuery, Par1, Par2, Par3,...,doQueryResult);
Where Par1, Par2, Par3 are the parameteres being passed to the doQuery cffunction.
Thanks for everyone's help.
Ros
Copy link to clipboard
Copied
quote:
Originally posted by: Rouset
I have a set of data, that is being collected and passed via javascript. So, my thought is to pass those data values from js to Coldfusion to write them back to the database. But, let me know if there is a better way to do that.
Thanks,
Ros
Care to elaborte on that first sentence with particular emphasis on the word "passed".

