jquery - 404 未在发布路线上找到
问题描述
我正在向这条路线发送一个帖子请求,但它不起作用并向我发送 404 Not Found Here 是该路线的代码
app.post('/case/new', (req, res) => {
Case.create({
name: req.query.name,
paid: req.query.paid,
assigned: req.query.assigned,
description: req.query.description,
date: req.query.date,
}, (err, created) => {
if(err){
console.log(err)
} else {
res.send(created)
}
})
})
我在这里使用 jQuery 发送请求是 jQuery 代码
$.ajax({
url: 'https://modern-clinic.herokuapp.com/new/case',
type: 'POST',
data: {
name: this.state.name,
description: this.state.desc,
paid: this.state.paid,
assigned: this.state.assigned,
date: this.state.date
}
})
解决方案
$.ajax({
url: 'https://modern-clinic.herokuapp.com/new/case',
type: 'POST',
dataType: 'json',
data: {
name: this.state.name,
description: this.state.desc,
paid: this.state.paid,
assigned: this.state.assigned,
date: this.state.date
}
})
推荐阅读
- html - 如何更改三列布局的不透明度
- javascript - 从 Google Maps Distance API 将 JSON 数据读入网页/html 表单
- c# - 切换到 MVVMLight 时出现 CanExecute 问题
- python - 使用来自 ipywidgets 的下拉小部件
- php - 使用 bash 脚本调用 PHP 方法
- gremlin - gremlin - 如何在单个查询中计算标准偏差?
- python - 将变量值从 python 传递到 shell 脚本以在那里使用它
- c# - 在 Oracle 中使用 select 语句插入数据时出现无效字符错误
- node.js - 服务器重新加载时发送到套接字
- c# - C# 我无法在 Zebra 中打印标签