微信小程序(以POST方式提交)

本文介绍了如何在微信小程序中实现以POST方式提交数据。在用户点击提交按钮时,首先获取必要的参数,如pjid、answer和score。接着计算score值,并调用接口URL。在进行POST请求时,设置合适的header,并根据条件传递数据。
摘要由CSDN通过智能技术生成

点击提交按钮时 首先获取到进入接口所需要的值  定义pjid  answer student score 为接口所需要的字段

    console.log(this.data.answer);
    console.log(this.data.score);
    console.log(_score);
    console.log(this.data.pj.pjid);
    console.log(this.data.pj.testpaperid);
    console.log(this.data.student);
      data:{
        pjid: this.data.pj.pjid,
        testpaperid: this.data.pj.testpaperid,
        answer: JSON.stringify(this.data.answer),
        student: JSON.stringify(this.data.student),
        score: _score
      },

计算score  调接口url: url,

 //计算分值{4:'10',5:'8'}
    var _score = 0;
    for (var i in this.data.score) {
      _score += parseInt(this.data.score[i]);
    }
    //判断分数值
    if(_score<this.data.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值