Replicating link_to_remote in raw js

This is an interesting problem:

I have a view that has a div that gets replaced by innerhtml using a
settimer() in js.

The settimer() invokes a js function (makemytable())that creates a
table in html based on json data that gets written on the server every
2 seconds.

So, every 2 seconds, the table in the div in the view automatically
updates itself. So far, tres bien, very good.

Now, I need to put links in some of the cells in the table -- but I
want them to be effectively link_to_remote's.

So waht I need to do is, since this innerhtml is finished html/js and
not ruby code, I need to put these link_to_remotes in in a pure js
manner from within makemytable(), which is itself a js.

So my question, the must be a way within js to replicate what
link_to_remote creates, no? How can I write out the finished page, in
effect, with links that operate like link_to_remote? Does anyone know
what that looks like? If I simply look at the source of a page I have
with a link_to_remote on it I see:

<a href="#" onclick="new Ajax.Request('/channels/userfreeze',
{asynchronous:true, evalScripts:true, parameters:'authenticity_token='
+ encodeURIComponent
('xgorbWtiTdb15yhJ9il0TbbD1szBHSAcWb7p6GVffF0=')}); return false;"
style="float: right; border-style: ridge; padding: 1px;" title="Make
user in box below be frozen" type="submit"><img alt="Freeze" src="/
images/freeze.gif?1247336897" /></a>

I assume I only need copy this text, altering what needs to be altered
interms of where I wantt it to call, etc. But what is the
authenticity_token? I am using AUthLogic plugin, could it be from
that?. Is that necessary here to put that text in too? -Janna B

Janna, it’s actually a feature of Rails to prevent cross site request forgery (CSRF). You can find

more details here:

http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html

Good luck,

-Conrad