I am setting up a site now that uses a lot of ajax interactions. The basic flow of what is going on now is data is validated both client-side and server-side, and if the data is correct the response from and AJAX post will be the url to the next page to go to.
When I receive the url client side I am currently using window.location = url to perform my redirect.
For some reason, something about this seems incorrect. Specifically, looking through a variety of open-source projects, I rarely see it. I am wondering if the interaction I am describing above is correct, and if it is not, what I could do differently to correct my current design.
What you are doing is completely fine and is the normal approach that people take. Something to keep in mind is how do you handle failed requests that is your post failed for some reason or there was failure in the ajax request etc.
There was an interesting so question and read the marked answer: How to manage a redirect request after a jQuery Ajax call
Hope this helped
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With