Redirection On Ajax Success Using Window.location.replace()
I am trying to redirect the page on the successful ajax call, the following code works fine, $.ajax( { type: 'POST', url: path, data: response1, conte
Solution 1:
The problem was that I was not specifying the protocol,
window.location.replace(window.location.protocol + "//" +
window.location.host + "/configuration/manage_users")
worked fine, I found out that,
window.location = window.location.protocol + "//" +
window.location.host + "/configuration/manage_users"
is better for redirection.
Solution 2:
Normally you could do this from server. You have to respond correct HTTP headers. What is your back end technology? In node.js it will look like this:
var host = 'http://172.16.17.141:81'
response.writeHead(302, {
'Location': host + '/configuration/manage_users'
});
response.end();
Solution 3:
Would this work?
$.ajax
type: 'POST'url: path
data: response1
contentType: 'application/json'success: ->
window.location = "//#{window.location.host}/configuration/manage_users"
Post a Comment for "Redirection On Ajax Success Using Window.location.replace()"