jquery-ajax - 使用AJAX(jquery)(json)时后台node.js(express)不能使用res.redirect重定向?
大家讲道理
大家讲道理 2017-04-17 15:30:10
0
3
742
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(3)
小葫芦

Actually, I figured it out after thinking about it myself. My needs also require the use of AJAX. If AJAX is not used, do we have to use URL with parameters to pass the password value at the risk of injection attacks?

Let me explain it carefully. First of all, it is true that you cannot redirect when using AJAX. There is no solution to this problem because after using AJAX, it is a complete process of request and callback. In this process, there is only one HTTP Header, if you redirect it will be repeated and an error will be reported.

Using AJAX is something on the same interface. Redirecting to other interfaces cannot break the entire request process of AJAX, because the redirect function changes the orientation in the middle of the AJAX request, which breaks the entire process of AJAX.

So if you want to make a login interface, then only AJAX returns the url to open the next step, and then the front end can be transferred.
Or don’t use AJAX.

伊谢尔伦

First of all, you need to understand what ajax is. Ajax is designed to partially refresh the page without re-refreshing the entire page. You do not need to use ajax technology to update your needs.

刘奇

Just jump on the front end as you said, ajax is originally used to obtain data,

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template