redirect to url taken from json response

javascript, jquery, json, php, redirect

Solution

I personally use

    window.location.replace(url);

Read More - "The replace() method replaces the current document with a new one" window.location.replace() better simulates a http redirect

There are other various options like:

window.location.href = "http://stackoverflow.com";

Which acts as a link click

Problem

I am using jquery ajax method to make http request to php webpage, and in response I am taking json like {"status":"success","url":"http url"} on success function I am redirecting to url from json but most of the time it fails. I am using following to redirect: ``` window.location.href = url ``` It works fine when url is clean with no other characters, but fails when I have # or space or some other characters. Please letme know if there is any way to solve my problem.

Original source