It should be noted that I am not very proficient at using Firebug, but I haven't found any errors that explain the following issue.
I have a feed.js.erb file containing the following code:
var $foos = $('<%= escape_javascript(render(@foos)) %>');
$('#container').append($foos);
$('#pagination_button a').attr('href', '<%= feed_path + '?page=' + @page %>');
When this ajax call is made the second time, it appears to fail silently. I see the appropriate response in the Firebug console, but $foos is not altered and subsequently the #container is never appended.
My html page only includes a loading indicator, which it successfully replaces on the first call. The second call is triggered from other javascript (Infinite Scroll).
If it matters, I have noticed that the first call is made with an automatically generated timestamp parameter. After that I am replacing the target url as you can see on my #pagination_button a.
How can I debug this in the browser?
Update: I used ERB to make $foos a dynamic variable ($foos1...$foos2) and noticed that this is also not working. So even though the new @foos are visible in the console's response, the first line of my javascript is not being evaluated. 
As it turns out, Rails is not processing my second request as JS. More importantly, if the JS raises an exception, it will be converted to plain-text as explained here. Steve also shows how to debug ajax code, effectively answering both of my questions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With