は私のルータのためのコードを持ってもらうNodeJSは500
var express = require('express');
var router = express.Router();
function sendSolve(test) {
// Some code for calculations
}
/* POST listing. */
router.post('/', function (req, res, next) {
sendSolve(req.body.data);
next();
}, function (req,res) {
res.json({"message": "ok"});
});
module.exports = router;
クライアントコード:
$('.button').on('click', function() {
var $textArea = $('#textArea');
var newData={data: $textArea.val()};
$.post('/', newData, function (res) {
console.log(res);
$textArea.val('');
});
});
そして私最初$.post
everythngはOKですが、第2のポストイムには、エラー 500 (Internal Server Error)k.cors.a.crossDomain.send @ jquery-2.1.4.min.js:4n.extend.ajax @ jquery-2.1.4.min.js:4n.(anonymous function) @ jquery-2.1.4.min.js:4(anonymous function) @ main.js:26n.event.dispatch @ jquery-2.1.4.min.js:3r.handle @ jquery-2.1.4.min.js:3
を取得
問題が発生している場所からフロントエンドコードを追加する必要があります。 curlまたはpostmanを使用すると複数の投稿にエラーが表示されますか? – vbranden