# Problems with ajax in Rails 3

**URL:** <https://www.ruby-forum.com/t/problems-with-ajax-in-rails-3/194622>\
**Category:** Rails\
**Created:** [September 8, 2010, 3:29am UTC](https://www.ruby-forum.com/t/problems-with-ajax-in-rails-3/194622 "2010-09-08T03:29:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![isaacchiang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/5e9695/32.png) [@isaacchiang](https://www.ruby-forum.com/u/isaacchiang)\
**Post date:** [September 8, 2010, 3:29am UTC](https://www.ruby-forum.com/t/problems-with-ajax-in-rails-3/194622/1 "2010-09-08T03:29:59Z")

</div>

Dear all:  
I’m new to Rails and I’ve encountered some problems with ajax in  
Rails 3. My project is on a Ubuntu 10.04 LTS machine with ruby v1.8.7  
and rails v3.0.0.

I’ve changed my rails.js file according to :

> <https://github.com/rails/jquery-ujs/blob/master/src/rails.js>

and also changed my javascript\_include\_tag to these three paths:

1.“[http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js](http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js)”  
2.“[http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js](http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js)”  
3.“rails.js”

Everything works just fine except a controller with a ssh connection  
behavior.

In my malfunctioned controller:

def remoteStatus  
@ip = params[:server][:ip]  
@sshid = params[:server][:sshid]  
@sshpass = params[:server][:sshpass]  
Net::SSH.start(@ip, @sshid, :password =\> @sshpass) do |  
session.exec!(“free | awk ‘NR==2 {print rate = $3/$2\*100}’”) do  
|channel, stream, data|  
@memusage = data  
end  
end  
respond\_to do |format|  
format.js  
end  
end

In the remoteStatus.js.erb I have:

$(‘#status\_div’).append(“\<%=@memusage%\>”)

I am pretty sure that I can have the ssh connection result in variable  
@memusage. But it seems that it never appends to the status\_div block in  
the corresponding view. I’m wondering if I am missing something  
detailed. Can anyone help me here,please and thanks!

Best regards
