Yes, but take this code for example:

"result" is a javascript variable which was returned by ajax.

It contains the following text:

function test() { alert('test'); }

Now I do 

eval(result);

OK, that runs, but NOW if you try to execute test(); you get an Object
Expected error because the test() function only lasts for the duration
of the eval call.  That is bad.

Here was my solution though.

I used the JavaScript found at
http://rabaix.net/index.php/en/articles/issues_developing_ajax_libraries
To loop over the returned HTML and strip out ALL JavaScript between
<script> tags.  THEN I looped over that and change the previous function
declaration format to:

window.test = function() { alert('test'); }

(The "window." Was unnecessary but I left it in there.)

NOW, when I eval() the above code, test() is STILL available as a
function in the window to be called.

Make Sense?

~Brad

-----Original Message-----
From: Andy Matthews [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 08, 2007 8:28 AM
To: CF-Talk
Subject: RE: Dynamic JS

You should be able to simply Eval() the returned javascript to "Run" it.
I'm
doing that in a script that's similar in nature to yours.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7 
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs 
http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:269178
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to