![](/img/trans.png)
[英]Django, Ajax and jQuery - posting form without reloading page and printing “succes” message for user
[英]jQuery/Ajax - Redirect to another page after succes message
填写联系表单后,我想重定向用户,并显示成功消息。
这是HTML代码:
<div id="wpm_download_1" style="display: inline;">
The link to the file(s) has been emailed to you.
</div>
这是我正在尝试的JavaScript:
function() {
var isDownloaded = jQuery('#wpm_download_1').text();
if (typeof obj.isDownloaded != 'undefined'){
window.location = 'http://google.com';
}
}
基本上,我想通过AJAX
发送表单数据后出现此消息时重定向用户:
文件的链接已通过电子邮件发送给您。
为什么使用obj.isDownloaded? 在这里工作:
jQuery('#wpm_download_1').text();
if (typeof isDownloaded != 'undefined'){
window.location = 'http://google.com';
}
由您决定何时需要调用该函数
在此之前,您必须调用函数。 对于重定向,请使用以下哪种方法:
window.location.href示例:
window.location.href = 'http://www.google.com'; //Will take you to Google.
window.open()示例:
window.open('http://www.google.com'); //This will open Google in a new window.
好吧,在努力之后,我才想到了这一点,并且成功了:
jQuery( document ).ajaxSuccess(function( event, xhr, settings ) {
window.location.href = 'http://google.com';
});
因为,我想在成功的AJAX请求完成后被重定向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.