在Ajax发布后重定向

编程入门 行业动态 更新时间:2024-10-10 05:24:07
本文介绍了在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发布后重定向

本文发布于:2023-10-12 05:11:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483809.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   Ajax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!