Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ajax 收到服务器端返回请求302,服务端给定重定向地址

服务端返回

{'code': 302, 'data': '/cms/'}

前端处理

$(function () {
  var url = window.location.pathname
  $.ajax({
      url: url+'logout',
      type: 'get',
      dataType:'json'
      success: function (data,status) {
          // var datas = JSON.parse(data)
          if(data.code === 302){
              location.href = data.data;
          }
          alert('重定向')
      },
      error: function (data) {
          console.log(data.toString())
      }
  })  
}