let params = new URLSearchParams();
params.append('id',xx)
axios({
url:'http://127.0.0.1:8000/userctrl/shoucang',
method:'post',
data:params,
responseType:"text",
})
.then(function(obj){
})
//后端取值:
Axios get:
axios({
url:'http://127.0.0.1:8000/userctrl/shoucang',
method:'get',
params:{'id':xx},
responseType:"text",
})
.then(function(obj){
})
//后端取值:
Ajax post:
$.ajax({
url:"http://127.0.0.1:8000/userctrl/shoucang",
data:{'id':xx},
type:"post",
async:false,
dataType:"text",
success:function(obj){
console.log(obj)
}
})
//后端取值:
Ajax get:
$.ajax({
url:"http://127.0.0.1:8000/userctrl/shoucang",
data:{'id':xx},
type:"get",
async:false,
dataType:"text",
success:function(obj){
console.log(obj)
})
//后端取值:
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:Django + Axios & Ajax post和get 传参 - Python技术站