The first interface just returns JSON, and the second interface returns a page. Is this the case? In this case, the process you described is no problem, but it requires two http requests; another way is to directly redirect the page to the first interface. After the first interface is verified, the server jumps to the second one. interface, and then return to a page. The advantage of the second method is that it is only one request for the user and only requires one network request.
1) Data validity verification needs to be done before and after. 2) After passing the data verification at the front end, submit the Ajax request to the backend. The backend will also perform data verification. If the verification fails, the result will be returned to the Ajax request. The front-end JS performs corresponding processing; after the background verification passes and the logic is executed, the processing result and the jump page link are returned (it is best not to return). After the Ajax request gets the request result, JS brings the necessary parameters to control the page jump~~ ~ 3) It is best not to handle jumps in the background. The background is only responsible for processing the received requests and returning the processing results, so that your background service can be decoupled from the front-end page
The first interface just returns JSON, and the second interface returns a page. Is this the case?
In this case, the process you described is no problem, but it requires two http requests; another way is to directly redirect the page to the first interface. After the first interface is verified, the server jumps to the second one. interface, and then return to a page.
The advantage of the second method is that it is only one request for the user and only requires one network request.
1) Data validity verification needs to be done before and after.
2) After passing the data verification at the front end, submit the Ajax request to the backend. The backend will also perform data verification. If the verification fails, the result will be returned to the Ajax request. The front-end JS performs corresponding processing; after the background verification passes and the logic is executed, the processing result and the jump page link are returned (it is best not to return). After the Ajax request gets the request result, JS brings the necessary parameters to control the page jump~~ ~
3) It is best not to handle jumps in the background. The background is only responsible for processing the received requests and returning the processing results, so that your background service can be decoupled from the front-end page