情况一、ajax请求必须为post方法,才能解析xhr.send中的请求体内容。
情况二、服务端必须设置解析参数的中间件。如下:
// 1. 导入解析表单数据的中间件 body-parser
const parser = require('body-parser')
// 2. 使用 app.use() 注册中间件
app.use(parser.urlencoded({ extended: false }))
情况一、ajax请求必须为post方法,才能解析xhr.send中的请求体内容。
情况二、服务端必须设置解析参数的中间件。如下:
// 1. 导入解析表单数据的中间件 body-parser
const parser = require('body-parser')
// 2. 使用 app.use() 注册中间件
app.use(parser.urlencoded({ extended: false }))