Get rid of a 401 (unauthorized) ajax error in browser console

后端 未结 2 1499
刺人心
刺人心 2021-02-20 06:11

I\'m calling an api through javascript using a jQuery.ajax call. The api respond with 401 if the user is not authenticated and I want to ignore this error only for this call.

2条回答
  •  孤城傲影
    2021-02-20 06:33

    Can you add a hidden field onto the page (i'm guessing its dynamically generated) like:

    
    

    Then in you javascript, place

    if ($('input[name=isLoggedIn"]').val() == "true")
    {
         //your ajax call here
    } 
    

提交回复
热议问题