当我向服务器发送数据时,如果 request.method == 'POST': print("************request body*******" )
在 django views.py 中。这些代码无法工作。
enter code here
var app6 = new Vue({
el: '#app-6',
data: {
realtimecost:0,
},
created() {
setInterval(() =>
{
this.realtimecost=this.realtimecost+1;
if(this.realtimecost==5)
this.sendData();// here
}, 1000);
},
methods: {
sendData:function ()//send data
{
var self = this;
reqwest({
url:'http://127.0.0.1:8000/tasks/',
method:'post',
type:'json',
headers: {
"X-CSRFToken": Cookies.get('csrftoken')
},
data:
{
realtimecost:5,
},//end data
success:function(resp){
//self.getData()
}//end success
})//end reqwest
},//end senddata
}//end method
})//end app6