302 when loading data using ajax

problem description

A problem encountered in projects today is that multiple projects (portal/oa/partform) are run in a tomcat, and then load data from the interfaces of these projects. First, call portal/index to enter the page, and then call the interface under portal/oa/partfrom to request data (ajax- > get), which returns 200 under the portal interface, and the others return 302;

).

clipboard.png

this happens only when the page is loaded for the first time (when the browser clears the cache), and there is no problem with refreshing the page when the page is loaded (when the browser has a cache).


looking at the screenshot seems to be a redirect due to lack of authentication. In general, many applications need to log in to query the page or call the interface to see if this is the reason.


after clearing the cache, log in again. Force the jump to the login page.

302 is a redirect. Generally, the redirected address Location ,

is returned in ajax.
var location = xhr.getResponseHeader('Location');

then re-launch the ajax request with location as the new address. Reference:
ajax Asynchronous request 302

Menu