I am trying to pass some data to my node.js server with an ajax request.
Unfortunately I my server logs an empty object and my ajax call doesn't log any success nor error.
Here's the snippet of my code:
var fd = new FormData();
function appendPicture(){
fd.append('picture_data', that.state.newFeedMediaData);
fd.append('content', that.state.newFeedContent);
fd.append('img_inline_style', img_inline);
}
var p1 = Promise.resolve(appendPicture());
p1.then(function(v){
console.log(fd);
$.ajax({
url: '/api/setNewFeedPost',
data: fd,
processData: false,
contentType: false,
enctype: 'multipart/form-data',
type: 'POST',
success: function(data){
console.log("success");
},
error: function(data){
console.log("error");
}
});
});
img_inline_style contains the following object:
{Filter: "grayscale(0%) brightness(100%) contrast(100%) sepia(0%)"
WebkitFilter: "grayscale(0%) brightness(100%) contrast(100%) sepia(0%)"
backgroundImage: ""
backgroundPositionY: -66
backgroundSize: "cover"
height: "100%"}
Even if there would be something wrong inside my sendObj I don't think thats the issue since even when I try to send some simple string like "test"
the request just doesn't happen.
Why would this be?
Additional info:
On my node.js server side im simply logging the received data which gets printed out simply like an empty object
Received data: {}
I am using node.js with express and my server side render script of an ajax post in my api file looks as following:
router.post('/setNewFeedPost', function(req, response, next){
console.log("Set new Feedpost content: ",req.body);
});