views.py中的代码:
# 处理jquery中load的请求
def load(request):
return JsonResponse({"name": "马亚南", "age": 28})
html中的代码:
<script>
$(document).ready(function () {
$("button").click(function () {
$("div").load("/load2/", function (ret, status, obj) {
if(status == "success"){
alert("加载成功");
}
else if( status == "error"){
alert("加载失败" + obj.status);
}
});
})
})
</script>