I am making an ajax call to my controller. Controller is sending in the
response in an instance variable(as a json object). How can I access the
same in my ajax javascript?

This is my ajax call code:

$(document).ready(function(){
var currentCellText;
$(".inline").click(function() {
currentCellText = $(this).text();
$.ajax({
type: 'GET',
dataType: "json",
url:'/test',
async: false,
data:{ foo1:currentCellText
},
dataType: "json",
success:function(data){
alert('<%= @response %>');
},
error:function(data){
alert("Error");
}
});
});
});

This is my controller code.

def some_action
# after assigning a value to variable response
@response = Response.where(some condition)
respond_to do |format|
format.html #this will simply render the view
format.json { render :json => { :response => @response } }
end
end

I am getting an empty square bracket as my output. I am not able to find
out where I am wrong. Please guide me through.

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to