浏览器向网站发送请求是:URL 和 表单的形式提交
Get
Post
特点:页面刷新
除此之外,也可以基于Ajax向后台发送请求(偷偷的请求,页面不会刷新)
依赖jQuery
编写ajax代码
$.ajax({
url:"发送的地址",
type:"get",
dataType:'JSON',
data:{
n1:123,
n2,456
},
success:function(res){
console.log(res);
}
})
<script type="text/javascript">
function clickMe(){
$.ajax({
url:'/staffmanagement/task/ajax/',
type:"get",
dataType:'JSON',
data:{
n1:123,
n2:456
},
success:function (res){
console.log(res)
}
})
}
</script>
def ajax(request): print(re