# Controller data in Ajax Modal

**URL:** <https://www.ruby-forum.com/t/controller-data-in-ajax-modal/226525>\
**Category:** Rails\
**Created:** [December 12, 2012, 2:21pm UTC](https://www.ruby-forum.com/t/controller-data-in-ajax-modal/226525 "2012-12-12T14:21:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikhilrkn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/9fc29f/32.png) [@nikhilrkn](https://www.ruby-forum.com/u/nikhilrkn)\
**Post date:** [December 12, 2012, 2:21pm UTC](https://www.ruby-forum.com/t/controller-data-in-ajax-modal/226525/1 "2012-12-12T14:21:39Z")

</div>

Hi,

I am fetching a set of data from the controller. The data set is in a  
cookie array. I have to display the set in a modal pop up. I am sending  
the request through an ajax call. How to display the array from the  
controller in the view in ajax in a modal box? I am using colorbox as my  
modal box.

.erb file:

$(document).ready(function() {  
var currentCellText;/_this variable will have the clicked cell value_/  
$(".inline").click(function(e) {  
currentCellText = $(this).text();

$.ajax({  
type: ‘GET’,  
url:’/leave’,  
async: false,  
data:{ foo1:currentCellText  
},  
success:function(data){  
$.colorbox({html: \<%= cookie[:event] %\>, width:“35%”,height:“400px”});  
},  
error:function(data){  
alert(“Failure”);  
}  
});

});

});

controller file:

cookie[:event] is having the data array.

If I print the cookie[:event] in the controller using a puts, I get the  
data set. But I am not able to achieve the same in the ajax modal box.

Regards,  
Nikhil
