ajax 提交数据

在ajax post的方式的时候,如果后台出现该接到对象数据但是总接到字符串数据的时候
type: 'POST',
data: {'evaluator_id':reverseId,'evaluate_comment':content},
contentType: "application/json",

后面接的是一个string的数据
Request Playload
evaluator_id=ff808081631fb8b301631fc44a060041&evaluate_comment=12

而 加上JSON.stringfy()后接到的数据就正常了
type: 'POST',
 data: JSON.stringify({'evaluator_id':reverseId,'evaluate_comment':content}),
contentType: "application/json",

之后,后面就接到了对象模式的数据
{evaluator_id: "ff808081631fb8b301631fc44a060041", evaluate_comment: "23"}
evaluate_comment:"23"
evaluator_id:"ff808081631fb8b301631fc44a060041"

猜你喜欢

转载自www.cnblogs.com/xk-g/p/9264225.html