$.post and nodeJS problem. (Never Success)
Hi,
I have a problem with a $.post.
I send a JSON file to my nodeJS server and it is well received by the server. (I can handle it with NodeJS)
But client-side, I never have the success of the $.post.
- saveJSONtoServer : function()
{
var self = this;
var JSONvar = self.makeJSON();
$.ajax(
{
url: "/handlerJSONentrySaver",
type: "POST",
data: JSONvar,
dataType: "json",
success: function(data)
{
alert("OK");
},
beforeSend: function(x)
{
if (x && x.overrideMimeType)
x.overrideMimeType("application/j-son;charset=UTF-8");
}
});
},
I have this code server-side :
- app.post("/handlerJSONentrySaver", function(req, res)
- {
- console.log(req.body);
- res.writeHead(200,{"Content-Type" : "text/html"});
- res.end("OK");
- });
Hope you can help me.
Thanks in advance.