小程序传输json数组给php后台处理
小程序不能直接上传json数组对象,先转化为json字符串再上传
代码:
onSelect(event) {
let that=this
let name=event.detail.name
let answer=this.data.answer
let queid=this.data.queid
let answerstr=JSON.stringify(answer) //json数组对象转化为json字符串
let status=""
let hash=wx.getStorageSync('hash')
if(name=="暂存"){
status=0;
}else{
status=1;
}
app.util.request({
'url': 'entry/wxapp/subanswer',
data:{status:status,answer:answerstr,queid:queid,hash:hash},
method:"post",
success: function (res) {
console.log(res.data);
if(res.data.data=="ok"){
that.setData({ show: false });
wx.showToast({
title: res.data.message,
})
return false;
}
2021-06-11 14:54:25
754人阅读
评论( 0 )