本文介绍了在Ajax发布后重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望ajax发布成功发布到主页.由于某种原因,我一直做错了.知道该怎么做才能解决这个问题吗?
I want the success on ajax post to go to the home page. For some reason I keep doing it wrong. Any idea what I should do to fix this?
window.APP_ROOT_URL = "<%= root_url %>";Ajax
$.ajax({ url: '#{addbank_bankaccts_path}', type: 'POST', beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', '#{form_authenticity_token}')}, dataType: "json", data: 'some_uri=' + response.data.uri , success: function(APP_ROOT_URL) { window.location.assign(APP_ROOT_URL); } });推荐答案
success: function(response){ window.location.href = response.redirect; }
希望以上内容会有所帮助,因为我遇到了同样的问题
Hope the above will help because I had the same problem
更多推荐
在Ajax发布后重定向
发布评论