I'm getting different results if I render js versus render json .Trying to figure out why this doesn't work quite as expected
My javascript looks like this:
$( function () {
$('.delete_post').bind('ajax:success', function () {
$(this).closest('tr').fadeOut();
}
)
});
Controller:
Works
respond_to do |format|
format.js { render :nothing => true}
end
Works
respond_to do |format|
format.js { head :ok }
end
Works
respond_to do |format|
format.json { render :json => {} }
end
Doesn't work
respond_to do |format|
format.json { head :ok }
end
Doesn't work
respond_to do |format|
format.json { render :nothing => true }
end
When I examine what is happening in the ajax response I see that the cases where it doesn't work I get a "parseError".
I understand that the Content-type getting sent back is different (text/javascript vs applicaiton/json), but I would still expect the last 2 cases to work since they are sending back a 200 to the server.
(Code derived from: http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/)