Upon making an ajax request, the JSON response contains a link that needs to redirect the user to another page after 3 seconds.
The current approach used is:
response = JSON.parse(res);
var link = response.link;
setTimeout("window.location.href=link",3000);
However, an error message occurs stating that link
is not defined, suggesting it is out of scope for the setTimeout function.
What alternative methods can be utilized to resolve this issue?