I have this jQuery in my Rails app:
$('#rankings_link a').click(function(){
$.ajax({
dataType: 'json',
contentType: 'application/json',
url: '/rankings',
type: 'get'
}).done(function(received_data){
for (var m = 0; m < received_data.length; m++) {
$('#rankings ol').append('<li>' + received_data[m] + '</li>');
}
});
});
At the end of the rankings method in my controller is:
:render => 'json'
But when I click on the #rankings_link, it sends me to /rankings and displays a large block of preformatted text like this:
["Farag, Ali", "Harrity, Todd", ...]
I want to be able to put each element of (what seems to be) the array in an ordered list. But clearly this isn't what's happening and I don't know why.
Thoughts?