java - 关于请求跳转的问题
高洛峰
高洛峰 2017-04-17 16:35:11
0
2
429

流程是这样的:
首先在页面通过ajax提交数据并进行数据的合法性验证,返回json格式的数据,验证通过后再提交其它参数到另一个链接。
可以在前端来控制跳转,但是还有其他参数需要校验或者跳转的页面中需要渲染模版内容。所以需要在后端来控制。不知道这个有什么好的流程没有?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all (2)
刘奇

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

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!