AJAX:成功重定向后,然后修改新页面 [英] AJAX: on success redirect then modify new page
问题描述
这可能真的很简单,但是我似乎找不到解决方法.我正在拨打AJAX,成功后我将重定向到另一个页面.那行得通.
This is probably really simple to do, but I can't seem to find the solution. I'm making an AJAX call, and on success I'm redirecting to a different page. That works.
我想要:重定向>在新页面上向用户显示消息
I want: redirect > display message to user on new page
我了解:在当前页面上向用户显示消息>重定向
I get: display message to user on current page > redirect
代码:
$('#delete').click(function() {
$.ajax({
type: "POST" ,
url: delete_url ,
data: {action_id: action_id } ,
success: function(response) {
if (response.success) {
window.location = action_list
$("#success").html(response.success);
} else {
$("#error").html(response.error);
$("#success").html("");
}
}
});
return false;
});
推荐答案
您可以将查询字符串中的参数传递到成功页面.添加到您的action_list
变量?success=1
.然后,在成功页面上,可以检查REQUEST["success"]
是否为1
,如果是,则显示成功消息.
You could pass a parameter in the query string to your success page. Add to your action_list
variable ?success=1
. Then on your success page you can do a check to see if REQUEST["success"]
is 1
and if so, display the success message.
这篇关于AJAX:成功重定向后,然后修改新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!