I make an ajax request, and the JSON response, after parsing, gives me the link to the page I want to redirect the user to after 3 seconds.
I’m doing it this way:
response = JSON.parse(res);
var link = response.link;
setTimeout("window.location.href=link",3000);
However, I get an error message that link is not defined, presumably because it isn’t in the scope of the setTimeout script.
How can I work around this?
Please don’t use a string for setTimeout.