Postman中x-www-form-urlencoded请求K-V的ajax实现

在Postman中使用x-www-form-urlencoded,并且用K-V传值,但是在代码中用ajax来请求,传值一直有问题,静下心来思考才发现K-V传入的是string,所以记录下来以防忘记!!!

在Ajax中需要将Value中的json转换为string:

let robotAuditStr = {"orderId":"","auditor":"","status":0, "type":2,"note":"test"};
$.ajax({
    url: `http://cloud.qiyi.domain/apis/audit/robotAudit`,
    type: "POST",
    contentType: "application/x-www-form-urlencoded",
    data: {robotAuditStr: JSON.stringify(robotAuditStr)}
})

猜你喜欢

转载自www.cnblogs.com/jayinnn/p/10417012.html