Javascript 从后端代码向引导通知发送数据
我正在使用一个模板,该模板使用以下内容,我希望从视图向其发送数据:Javascript 从后端代码向引导通知发送数据,javascript,django,twitter-bootstrap,bootstrap-notify,Javascript,Django,Twitter Bootstrap,Bootstrap Notify,我正在使用一个模板,该模板使用以下内容,我希望从视图向其发送数据: try: # things except Exception as e: options = { "icon": "glyphicon glyphicon-warning-sign", "title": "Bootstrap notify", "message": "Turning standa
try:
# things
except Exception as e:
options = {
"icon": "glyphicon glyphicon-warning-sign",
"title": "Bootstrap notify",
"message": "Turning standard Bootstrap alerts into 'notify' like notifications",
"url": "https://github.com/mouse0270/bootstrap-notify",
"target": "_blank"
}
return JsonResponse(options)
在本例中,显示消息,但忽略所有其他选项,如“图标”和“标题”
在JS中,做同样的事情看起来像:
$.notify({
// options
message: 'Hello World' ,
title: 'your title'
},{
// settings
type: 'danger'
});
你知道如何解决这个问题吗?你可以这样做,让
http://localhost:8000/notify-选项/
$.get("http://localhost:8000/notify-options/", function(data, status){
$.notify(data,{
// settings
type: 'danger'
});
});
您能用您处理
JsonResponse
的方式更新问题吗?这可能就是问题所在。请使用接收JsonResponse的代码进行更新。否则您的问题无法回答。这里发生了什么JsonResponse(options)
?请分享更多详细信息,以便了解问题您确定没有任何内容覆盖您的引导通知css吗?如果您可以截图并在浏览器开发工具的控制台选项卡中显示所有消息,这将非常有用。