我有风景
def approval(request, id):
if request.method == "POST":
messages.add_message(request, messages.INFO, 'You have activity was recorded')
return HttpResponse({"success": "ok"})
else:
return HttpResponse(request.method + " not allowed")
对上面视图的ajax调用看起来像
$.ajax({
url: url,
type: "POST",
data: {"comment": comment, csrfmiddlewaretoken: '{{ csrf_token }}'},
success: function (data) {
location.href = "/redirect_url/";
}
});
但是,该消息在jquery URL /redirect_url
上不可见。