Been stuck on this for a while now, and My JavaScript is very limited! Have a book on order but for now i am stuck.
I am trying to refresh a Partial on my index page every 3 seconds with Jquery and AJAX.
# agents_controller
def refresh_partial
render :partial => "agents/dynamic"
end
#the js
<script type="text/javascript">
$(document).ready(
function() {
setInterval(function() {
$('.dynamic').load('/agents/refresh_partial');
}, 3000);
});
</script>
But all i get is
stack level too deep
but no stack trace.
My guess is that is is calling the partial infinitely, but i cant see how or why?
ANy suggestions? Im very new at all this but learning fast, with a book in each hand and really appreciate you guys' support!
Pulling from the answer in this question Reloading partial in an rails app but it is not working for me.
For Completness:
#/agents/index
<div class="dynamic"><%= render partial: 'dynamic' %></div>
#/agents/_dynamic
<div class="span4">
<table class="table table-striped" >
<% if @ttb.nil? %>
<% else %>
<% @ttb.each_slice(3) do |elem| %>
<tr>
<td><% elem.each_slice(3) do |a,b,c| %></td>
<td><%= a.gsub(/[^0-9A-Za-z]/, '') %></td>
<td><div id="content"><%= b.gsub(/[^0-9A-Za-z]/, '') %></div></td>
<td><%= c.gsub(/[^0-9A-Za-z]/, '').scan(/.{2}|.+/).join(":") %></td>
</tr>
<% end %>
<% end %>
<% end %>
</table>
</div>
Can anyone see what a cocked up or misunderstood?
Many Thanks