简体   繁体   中英

redirect to login page in AJAX requests

In my JS code I'm checking for a 403 status code on AJAX response and redirect to login page like this:

$.ajax({
 statusCode: {
   403: function() {
      window.location.href = "/login";
   }
 }
});

Should I use the full url to my site like the follows:

 403: function() {
      window.location.href = "www.mysite/login";
   }

Or it's enough to use the relative one?

使用相对URL应该足够了。

would it be faster to try with relative url to see if it's working than posting here ?

I think it will work with relative url

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM