How can I elegantly handle devise's 401 status in AJAX?

后端 未结 7 1963
庸人自扰
庸人自扰 2020-12-23 18:53

With devise one uses before_filter :authenticate_user! to restrict access to authenticated users only.

When an unauthenticated

相关标签:
7条回答
  • 2020-12-23 19:58
    $(document).ajaxError(function (e, xhr, settings) {
            if (xhr.status == 401) {
               $('.selector').html(xhr.responseText);
            }
        });
    
    0 讨论(0)
提交回复
热议问题