比方说,我在add-project.html
页面上有一个表单。请求完成后,我将用户重定向回主页面index.html
页面。重定向后在目标页面上显示通知
我想要做的是在用户成功提交表单时显示通知index.html
只有。
我的插件使用本作的通知:http://redeyeoperations.com/plugins/Notify/
现在,我使用的是临时的解决方案,它显示了add-project.html
通知当表单已经提交,再经过重定向到主index.html
页一个setTimeout
但我不喜欢它,它很脏。
$('#printForm').submit(function(e) {
e.preventDefault();
$.ajax({
type: 'POST',
url: 'add-project.php',
data: $('#printForm').serialize(),
success: function(result) {
if(result == '1') {
// Success
$.notify.basic('Congratulations, your projet has been saved correctly', {
occupySpace : true,
close : true,
autoClose: 5000
});
setTimeout(function() {
window.location.href = '../index.html';
}, 2000);
}
else {
// Error
$.notify.error('Oops, something went wrong ! Make sure you filled all the necessary fields', {
occupySpace : true,
close : true,
autoClose: 5000
});
}
}
});
});
有没有干净的方式显示在目标页面上的通知重定向之后?
感谢您的帮助。
为什么不尝试使用ajaxLoad? – Fredy 2012-07-11 07:50:46