1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Effect a redirect via ajax response

Discussion in 'XenForo Development Discussions' started by Zenexer, Mar 16, 2014.

  1. Zenexer

    Zenexer Active Member

    I have a basic form that's using AutoValidator to process submissions via ajax. If successful, I'd like to redirect the user to the resource created as a result of the request. This is easy enough to do via JavaScript, but I'm surprised that I can't find this functionality intrinsically. It looks as though normal redirect responses are deliberately ignored for ajax requests; however, the data is still passed to JavaScript event handlers, and I can run window.location.assign(event.ajaxData._redirectTarget) manually.

    Is there some way to do this without additional JavaScript to handle the response?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    Add:

    data-redirect="on" to your form.
     
    Zenexer likes this.
  3. Zenexer

    Zenexer Active Member

    Thanks, that did the trick.
     

Share This Page