1
REST nodejs 서버와 JavaScript/Zepto 클라이언트로 앱을 개발합니다. Json을 nodejs 서버로 보내기
$.ajax({
type: 'POST',
url: 'http://localhost:3000/request',
data: JSON.stringify({test : "test"}),
contentType: "application/json; charset=utf-8",
dataType: "json",
complete: callback,
processData : false,
success : function(){
console.log("toto");
},
error : function(){
console.log("erreur")
}
});
그리고 내 노드 코드 :
app.post('/request', request.request);
// request.js
exports.request = function(req, res){
console.log(req.body);
res.header("Access-Control-Allow-Origin", "*");
res.send("OK");
}
내 서버 여기
내 클라이언트에서 JSON 문자열을 보내려고
클라이언트 코드 하지만 노드 콘솔에서 다음을 인쇄합니다. {{test : "test"} : ""}
뭐가 잘못 됐니?