Grails: Page won't redirect after completed Ajax call

后端 未结 2 1633
耶瑟儿~
耶瑟儿~ 2021-01-22 11:01

This is my ajax call:

相关标签:
2条回答
  • 2021-01-22 11:49

    Redirecting the ajax call only redirects that call, not the whole page. To get the whole page to redirect, you either need to capture the redirected ajax call in the JavaScript and do a redirect from the JavaScript, or you need to have the page-level action do the redirect.

    0 讨论(0)
  • 2021-01-22 12:07

    Browsers won't redirect if an AJAX call returns a redirect. If you want to send the user to a new page after an AJAX call, you'll need to do so yourself in Javascript. Example:

    def url = createLink(controller: 'user', action: 'authenticate')
    render(contentType: 'text/html', text: "<script>window.location.href='$url'</script>")
    

    Ensure the AJAX response gets rendered by the browser. With the grails remoteFunction tag you should specify an element to update with the update attribute.

    0 讨论(0)
提交回复
热议问题