Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- client-side:
- var keys = {a:1,b:2};
- var formdata = new FormData();
- formdata.append("keys", JSON.stringify(keys));
- var ajax = new XMLHttpRequest();
- ajax.open("POST", window.location.pathname);
- ajax.send(formdata);
- server-side:
- app.use(bodyParser.urlencoded({ extended: false }));
- app.use(bodyParser.json());
- ...
- console.log(request.body.keys); //expected [Object Object] ({a:1,b:2}), result: undefined
- console.log(request.body); //actual result "{}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement