# trouble with basic remote\_function usage

**URL:** <https://discuss.rubyonrails.org/t/trouble-with-basic-remote-function-usage/43731>\
**Category:** rubyonrails-talk\
**Created:** [June 24, 2009, 3:04pm UTC](https://discuss.rubyonrails.org/t/trouble-with-basic-remote-function-usage/43731 "2009-06-24T15:04:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NaijaGuy](https://avatars.discourse-cdn.com/v4/letter/n/9e8a1a/32.png) [@NaijaGuy](https://discuss.rubyonrails.org/u/NaijaGuy)\
**Post date:** [June 24, 2009, 3:04pm UTC](https://discuss.rubyonrails.org/t/trouble-with-basic-remote-function-usage/43731/1 "2009-06-24T15:04:47Z")

</div>

I've tried moving the code around in different ways, but so far I haven't gotten remote\_function to work for me (I'm using Rails 2.3.2 on my Mac). I want to make an AJAX call when I double-click a word on my page, and the Javascript function is being called when the ondblclick event is fired, but nothing happens when it gets to my the "new Ajax.Request" part of my function. The Rails console doesn't even show it as making a call to my controller.

There is a DIV called "definition\_box", so my remote\_function call used to read like this:

\<%= remote\_function(:update =\> "definition\_box", :url =\> { :action =\> :lookup } ) %\>

Then I read

> **[A Rails, Ajax and RJS issue - seeing JavaScript in your HTML](http://craiccomputing.blogspot.com/2009/02/rails-ajax-and-rjs-issue-seeing.html)**
>
> Here's an example of the dangers of following tutorials too closely... I want to use Ajax on a web page to monitor the completion of a job ...

this and took that out since supposedly it might be duplicating the reference to the DIV (here in the view and in the controller), so now it looks like this:

\<%= remote\_function(:url =\> { :action =\> :lookup } ) %\>

As you can see, I'm not even trying to pass the Javascript parameter to remote\_function at the moment. My Javascript function looks like the following and does show me the alert box:

function lookupWord(t) {

&nbsp;&nbsp;alert('moving forward');

&nbsp;&nbsp;\<%= remote\_function(:update =\> "definition\_box", :url =\> { :action =\> :lookup } ) %\> &nbsp;&nbsp; &nbsp;&nbsp;}

This is what I currently have in my controller:

class HomeController \< ApplicationController &nbsp;&nbsp;def index &nbsp;&nbsp;end

&nbsp;&nbsp;def lookup() &nbsp;&nbsp;&nbsp;&nbsp;logger.debug('here') &nbsp;&nbsp;&nbsp;&nbsp;render :update do |page| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;page.replace\_html 'definition\_box', 'Done!' &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;end end

There used to be a new line in my routes.rb, but it seems like if I'm going to the same controller, that doesn't need to be there. I tried adding this and still my controller action debug statement doesn't show up in the server console:

map.connect 'lookup', :controller =\> 'home', :action =\> 'lookup'

Can you tell me why the text in my definition\_box DIV is not changing to "Done!" ???
