在我的 django oscar 项目中,我有一个愿望清单模板,其中包含从愿望清单中删除产品的按钮。该产品在 ajax 调用后被删除,但在 deleteview 中创建的成功消息正在刷新页面后加载。
问问题
767 次
1 回答
0
在views.py中,返回
response = {
'msg': render_to_string(
'messages/wishlist-msg.html',
{
'message': msg,
},
),
}
return HttpResponse(
json.dumps(response),
content_type='application/json',
)
愿望清单-msg.html
<div class="message-notification">
{{ message }}
</div>
当ajax成功时,js文件
const $message = $('.message-notification');
# code for ajax
done(function (data) {
message.append(data['msg']);
});
于 2019-08-15T13:19:46.197 回答