【前端】Ajax方法获取返回值
接口返回值:{"message": "put successful","data": {"num_22": 7,"num_27": 1,"num_2": 3,"num_30": 5},"success": "true"}ajax中几个重点重点都卸载备注里面了$.ajax({type: "POST", //提交方式url: BASE + "/sendHist
·
接口返回值:
{
"message": "put successful",
"data": {
"num_22": 7,
"num_27": 1,
"num_2": 3,
"num_30": 5
},
"success": "true"
}
ajax中几个重点
重点都卸载备注里面了
$.ajax({
type: "POST", //提交方式
url: BASE + "/sendHistoryDataToDirectional",
async: false, // 重点,false是同步,true是异步
dataType:'json', // 需要写上
data: {
beginDate: beginDate,
endDate: endDate,
sendType: sendType
},
success: function (result) {
console.log(result) // 打印出返回的值
if (result.success == "true") // 通过 “.key” 的方式能获取返回json中的value,例如:result.success
$.messager.alert({
title: '交付结果为',
msg: "交付结果为:交付成功量(2):" + result.data.num_2.toString() // .toString() 将结果转换成string类型,
});
else {
$.messager.alert({
title: '交付失败',
msg: result.message.toString()
});
}
}
})
更多推荐
活动日历
查看更多
直播时间 2025-02-26 16:00:00


直播时间 2025-01-08 16:30:00


直播时间 2024-12-11 16:30:00


直播时间 2024-11-27 16:30:00


直播时间 2024-11-21 16:30:00


所有评论(0)