2014-07-11 1 views
0
   <script type='text/javascript'> 
       $(document).ready(
         function() { 
          $('#loading').fadeOut(); 
          $('.adminMenu').click(function(e) { 
           $('#loading').fadeIn(); 
           e.preventDefault(); 
           $('#container2').html(""); 
           var url = $(this).attr("href"); 
           if(url == 'home.htm') { 
            window.location.reload(); 
            return true; 
           } 
           $('title').html($(this).attr('title') + ' :: DNA ADMIN 1.0'); 
           $('#activeTabId').val($(this).attr("id")); 
           $('#activeTabUrl').val(url); 
           $.ajax({ 
            async : true, 
            cache : false, 
            type: "POST",  
             url: url, 
             dataType: "html", 
             success: function (res) { 
              try { 
               $('#container2').html(res); 
              } catch(err) { 
               console.log(err); 
               console.log(url); 
              } 

              $.browser.mozilla == true ? $('html').scrollTop(0) : $('body').scrollTop(0); 
              $('#loading').fadeOut(); 
             }, 
             **error: function (xhr, ajaxOptions, thrownError)** { 
              console.log(xhr.status); 
              if(xhr.status=='403' || xhr.status=='500') 
              { 
               window.location.reload(); 
              } 
              $('#container2').html('<h4>Could not load the requested content.</h4>'); 
              $.browser.mozilla == true ? $('html').scrollTop(0) : $('body').scrollTop(0); 
              $('#loading').fadeOut(); 
             }, 
            }); 
          }); 
         }); 
       </script> 

     when my session is clear ajax error is not called while executing. 
     **error: function (xhr, ajaxOptions, thrownError)** 

     my question is if i clear session from cookies than my page should be reload. 
     when my session is clear ajax error is not called while executing. 

when session is clear ajax error will not check status code. want to redirect login.htm when ajax give error or reaload page. 

세션이 완료되면 아약틱 오류로 인해 상태 코드가 점검되지 않습니다. ajax가 오류 또는 리로드 페이지를 줄 때 login.htm을 리디렉션하려고합니다. 세션이 종료되면 Ajax 오류로 인해 상태 코드가 확인되지 않습니다. ajax가 오류 또는 리로드 페이지를 줄 때 login.htm을 리디렉션하려고합니다.세션이 깨끗하면 아약스 오류는 상태 코드를 확인하지 않습니다. ajax가 오류 또는 리로드 페이지를 넘길 때 login.htm을 리디렉션하려고합니다.

 my question is if i clear session from cookies than my page should be reload. 
     when my session is clear ajax error is not called while executing. 

when session is clear ajax error will not check status code. want to redirect login.htm when ajax give error or reaload page. 

세션이 완료되면 아약스 오류로 인해 상태 코드가 확인되지 않습니다. ajax가 오류 또는 리로드 페이지를 줄 때 login.htm을 리디렉션하려고합니다. 세션이 종료되면 Ajax 오류로 인해 상태 코드가 확인되지 않습니다. ajax가 오류 또는 리로드 페이지를 줄 때 login.htm을 리디렉션하려고합니다.

답변

0

성공의 문에서 상태 코드를 얻을 시도하고 그것을 가치 :

success: function(data, textStatus, jqXHR){ 
    var statusCode = jqXHR.status; 
    var statusText = jqXHR.statusText; 
} 

을하거나 statusCode에서 $ 아약스 호출

$.ajax({ 
    statusCode: { 
    403: function() { 
     window.location.reload(); 
    } 
    } 
}); 
으로 시도
관련 문제