【发布时间】:2016-07-17 15:56:13
【问题描述】:
为什么我的数据没有呈现在html板上,函数被调用,我检查了,请看我的js代码和html,控制台没有错误
<!-- HTML -->
<div class="model" type="x-tmpl-mustache"><h1>{{model}}</h1> </div>
// JavaScript
$(document).ready(function(){
$.get("/portfolio/model", function(data){
console.log(data
$('div.model').html(data);
});
# Python view
class Return_portfolio(LoginRequiredMixin, View):
template_name = "dashboard.html"
def get(self,request):
user = request.user
model = Portfolio()
model_id = model.recommended_portfolio(request, user)
print(model_id)
if request.is_ajax():
return JsonResponse({'model':model_id})
return render(request, 'dashboard.html',{'portfolio_view':True})
def post(self,request):
return HttpResponseNotAllowed(['GET'])
【问题讨论】: