let name = 'xiaohei';
let age = 18;
let data = {
"info":[{
"name":name,
"age":age
}]
}
//请求方式代码
$.ajax({
type: "POST",
url: "http://localhost:8000/", //接口地址
contentType: "application/json", //必须有
dataType: "json", //表示返回值类型,不必须
data: JSON.stringify(data),
success: function (res) {
console(JSON.stringify(res));
}
});