If test.cfm has other markup then you need to rethink your use of cfwddx.
Just throw an cfoutput around everything you want to return to the calling
page. When the calling page receives the contents of test.cfm in the success
handler, then you can do something with it. In this case, I'm dumping the
entire contents of the cfm page into a div on the html page. Check it out:

TEST.cfm
--------
<cfset myVar = 10>
<cfoutput><b>#myVar# times #myVar# is #myVar * myVar#</b></cfoutput>


TEST.html
---------
<html>
<head>
        <title> new document </title>
        <script src="jquery/jquery-1.3.1.min.js"
type="text/javascript"></script>
        <script type="text/javascript">
        <!--
                $(document).ready(function(){
                         $.get('test.cfm', function(data){
                                 $('#myDiv').html(data);
                         });
                });
        //-->
        </script>
</head>
<body>
        <div id="myDiv"></div>
</body>
</html>

-----Original Message-----
From: Victor Moore [mailto:[email protected]] 
Sent: Sunday, January 24, 2010 5:55 PM
To: cf-talk
Subject: Re: jQuery loaded page and <cfwddx


Yes, it helped crystallizing some ideas.

In my case test.cfm has a lot of other html markup and if I do an eval I get
an error.

I have tried sticking the javascript in a div and getting it after, which I
can and I can evaluate it too and dump the content to the console, but if I
try to access d i still get and undefined error.

Thanks again for your support
Victor

On Sat, Jan 23, 2010 at 8:50 PM, lists <[email protected]> wrote:
>
> Victor...
>
> What version of CF are you using? Can you share your code? That would 
> be much simpler. I went ahead and threw together a quick example of 
> how cfwddx and an ajax call should work. Both files should be placed 
> in the same directory. Note that when test.html first loads, you'll 
> get an alert with plain text...that's the string that's actually being 
> returned by the cfm page. Before it can be used as JavaScript, it must
first be evaluated.
>
>
> TEST.CFM
> ---------
> <cfscript>
>        myStruct = {};
>        myStruct['one'] = 1;
>        myStruct['two'] = 2;
>        myStruct['three'] = 3;
> </cfscript>
> <cfwddx action="cfml2js" input="#myStruct#" topLevelVariable="d">
>
>
> TEST.HTML
> ---------
> <html>
> <head>
>        <title> new document </title>
>        <script src="jquery/jquery-1.3.1.min.js"
> type="text/javascript"></script>
>        <script type="text/javascript">
>        <!--
>                $(document).ready(function(){
>                        $.get('test.cfm', function(data){
>                                alert(data);
>                                eval(data);
>                                console.log(d);
>                                alert(d['two']);
>                        });
>                });
>        //-->
>        </script>
> </head>
> <body>
>        <!--- left empty --->
> </body>
> </html>
>
> Hope this helps you out.
>
> -----Original Message-----
> From: Victor Moore [mailto:[email protected]]
> Sent: Saturday, January 23, 2010 6:55 PM
> To: cf-talk
> Subject: Re: jQuery loaded page and <cfwddx
>
>
> Yes, it's a get.
> It seems that after I restarted the browser the jQuery event click on 
> the button works.
> But I still can't access the toplevelvariable that was setup by the 
> cfddx call when the page was loaded.
>
> Thanks
> Victor
>
> On Sat, Jan 23, 2010 at 6:27 PM, lists <[email protected]> wrote:
>>
>> I assume you're using a get call. What happens when you console.log 
>> the argument passed to your success callback function?
>>
>> If you're not using getjson Then most likely you need to evaluate the 
>> argument before it's ready to be used.
>>
>> On Jan 23, 2010, at 2:06 PM, Victorng  Moore <[email protected]>
>> wrote:
>>
>>>
>>> Hi,
>>>
>>> I am loading a cfm page with jQuery.
>>> On that page I use <cfwddx.. action="cfml2js"...
>>> If I try to access the top variable and it tells me that it's 
>>> undefined, bu I can clearly see it in firebug if i expend the jQuery 
>>> call that it's there.
>>>
>>>
>>> any idea what I'm missing?
>>>
>>> Thanks
>>> Victor
>>>
>>> PS BTW i have also tried to trigger  a click event on a button on 
>>> the page and it's not being triggered.
>>>
>>> I have tried using the live function too with no success
>>>
>>> $("input:button[name='test']").live ("click", function(){
>>>            alert (this.id);
>>>            });
>>>
>>> No error but no alert...
>>>
>>>
>>
>>
>
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:330093
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