这是我的网址格式:
url(r'^(?P<pk>\d+)/view/$', views.leave_view, name='leave_view')
my views.py
def leave_view(request,pk):
leaves=leave.objects.get(id=pk);
data=dict()
if request.method == 'POST':
data['html_form']= render_to_string('m_manage/view_modal.html', {'leaves':leaves}, request=request)
return JsonResponse(data)
我的电话 js ----点击按钮调用
<script>
$("#table").on('click', '.view', function (e) {
var btn = $(this);
console.log(btn);
var url = btn.attr("data-url");
console.log(url);
$.ajax({
// url: '/m_manage/leave_view/',
url: btn.attr("data-url"),
dataType: 'json',
type: 'get',
success: function (data) {
console.log('You Did it!!!!');
console.log(data);
$("#modal-leave .modal-content").html(data.html_form);
}
});
});
</script>
我的console.log(数据)打印没有,虽然我从url收集主键并编写查询...为什么没有数据...