我一开始以为的Ajax请求设置RequestBody为json格式就完了,但是没有想到,当我在使用有人云API接口的时候,查看文档,让我懵逼了。tm的RquestHeader怎么设置为application/json。
后来度娘了以后大部分都是如何设置RequestBody为application/json格式。RequestHeader的说明很少。所以在此记录一下
Ajax设置Request Body为JSON格式
var account = {
"account": "15901085978",
"password": "23b9f889d2826d224d16eb9399652695"
};
account = JSON.stringify(account);
$.ajax({
type: "post",
url: "http://localhost/login",
contentType: "application/json; charset=utf-8",
data: