接口返回值:

{
    "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()
            });
        }
    }
})
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐