Redirect to new page from ajax request

32 views
Skip to first unread message

Константин Комков

unread,
May 22, 2019, 7:32:34 AM5/22/19
to web2py-users
Hello! I use ajax request and in one case of 10 I need redirect user to another page. Can I redirect user on server or I need return link in ajax answer to js, and then redirect user? Now if I use redirect on server redirecting page was loaded in console.

Leonel Câmara

unread,
May 22, 2019, 9:21:31 AM5/22/19
to web2py-users
you can use redirect(URL(..), client_side=True)

Константин Комков

unread,
May 23, 2019, 3:01:34 AM5/23/19
to web2py-users
In that case 'redirect(URL('bak','swed'), client_side=True)' console is clear, and no actions for user. My code now:
ajaxAnswer = '["11"]'
return ajaxAnswer
JS
function showMsg(data) {
data = JSON.parse(data);
...
else if (data[0]==11) {
document.location.replace("https://oas.timacad.ru/application/bak/swed");
}



Reply all
Reply to author
Forward
0 new messages