How to manage a redirect request after a jQuery Ajax call ?
There are 2 possible responses for performing ajax request.They are
- Redirects the browser to a new page
- Replaces an existing HTML form on the current page with a new one.
The jQuery code for doing these request
We also add custom header to the response.
To set the header on the response take care after the redirect because the page may be transparent to the ajaxSucces handler.
Read AlsoAbort Ajax request using jQuery
- To implemented the solution using wrapper for the callback function of the Ajax call.
- The wrapper checks the speicfic element is exist then returned HTML chunk.
- If the element was found then the wrapper executed a redirection.
- Otherwise, the wrapper forwarded the call to the actual callback function.
Example for wrapper function:
Making an Ajax call,we simply using the Ajax handler
Another way of doing ajax redirection is to simply reload the page and redirect when we get returned contentType of text/html
Read AlsojQuery Ajax file upload
Use the low-level
Also try this