> values = { dsn: '<cfoutput>#application.dsn#</cfoutput>' }

This seems rather perverse, is there really a good reason for the client to
know the datasource name?

My preference for doing Ajax data saves is to take a regular form that will
work without js, then do the following:

<form action="action.cfm(whatever)" id="myform...>..</form>

$('.myform').submit(function(e){
 e.preventDefault();
var target = $(this).attr('action');
var postData = $(this).serialize();
postData.ajax = true; // to differentiate this from a regular post
 $.post( target, data, function(data){
 //js code to handle response from server
});
});

In this instance, action.cfm will behave almost the same for a user with or
without js - the only difference being what it does after process the data.
If form.ajax exists and is true, spit out some JSON response; otherwise,
redirect user to confirmation page or whatever. The js ideally should
neither have nor need any server side knowledge.

HTH

Dominic



2009/9/9 Dave l <[email protected]>

>
> values = { dsn: '<cfoutput>#application.dsn#</cfoutput>' }
>
> So lemme get this straight... you are going to put your dsn into a js var?
> You might as well just output it on the page for all to see ;)
>
> You can change extension or output the cfm into a dummy container and then
> have jquery pick it up after it loads. If you change extension and it loads
> before document ready and you have code dependent on that then you are gunna
> be SOL. Now a good js programmer might get around this but if you are asking
> then you ain't one of them! ;)
>
> However the best way would probably be to use jquery to "load" the cfm code
> after it loads.
>
> say I have a cfm page called data.cfm that has a table that has user info
> and a cfc call. I want this to load after dom sometimes because say I
> add/update/delete a user without leaving page but want the table to update..
> I just run the ajax call and then reload the data,cfm page to fill it back
> in like so:
>
> $(document).ready(function() {
>    $("#submit").click(addPhoto);
>    $('#dataresponse').hide();
>    $('#load').hide();
>    $(".submitIt").hide();
>    $("#galleryTable").load("data.cfm");
>
>
>
>
>
> >Hi, all.
> >
> >
> >
> >I've decided to try to use some external .js files for a login routine for
> a
> >site management area
> >
> >instead of repeating the jQuery code on every page checking for login
> status
> >and running ajax
> >
> >login routines.
> >
> >
> >
> >I just realized, however, that when I put my jQuery code into an external
> >.js file, that CF will no longer
> >
> >process the CF variables I use in the jQuery code, typically for the
> >#application.dsn# variable, as in:
> >
> >
> >
> >$(document).ready(function() {
> >
> >
> >
> >values = { dsn: '<cfoutput>#application.dsn#</cfoutput>' }
> >
> >
> >
> >When that code is part of a .cfm file, of course the #application.dsn# is
> >processed,
> >
> >but in the external .js file, it's not.
> >
> >
> >
> >Other than hard-coding the dsn name into the value for the js, what
> >alternative is there
> >
> >for this situation?
> >
> >
> >
> >Thanks for any suggestions.
> >
> >
> >
> >Rick
> >
> >
> >
>
> >----------------------------------------------------------------------------
> >---------------------------------------
> >
> >"Those who hammer their guns into plows will plow for those who do not."
>  -
> >Thomas Jefferson
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326131
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to