I am trying to redirect the page on the successful ajax call, the following code works fine,
$.ajax(
{
type: "POST",
url: path,
data: response1,
contentType: "application/json",
success: ->
window.location.replace("http://172.16.17.141:81/configuration/manage_users")
});
Problem with this approach is that the path I am giving is fixed, I want something like,
$.ajax(
{
type: "POST",
url: path,
data: response1,
contentType: "application/json",
success: ->
alert(window.location.host + "/configuration/manage_users")#Gives right path
window.location.replace(window.location.host + "/configuration/manage_users")
#Does not work, I even tried window.location.host.toString()
});
The page does not redirect with the above approach and instead of the URL, the page redirects to "about:blank".
Any help will be appreciated.
The problem was that I was not specifying the protocol,
worked fine, I found out that,
is better for redirection.
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:
Would this work?