Redirect to after successful ajax form

后端 未结 3 1920
执笔经年
执笔经年 2021-02-20 12:03

I\'ve got a form with remote => true. And right now my controller looks like:

  # POST /items
  # POST /items.json
  def create
    @item = @store.items.build(pa         


        
3条回答
  •  猫巷女王i
    2021-02-20 12:30

    I think it might be impossible. The response to a Ajax request is processed by XMLHttpRequest. If a 3xx response is returned, XMLHttpRequest will follow the redirect itself, if the URL is of same origin. No matter how you set the headers, the browser cannot be aware of that. So the only way could be changing window.location with some Javascript.

提交回复
热议问题