Having some trouble getting express to respond properly to my jquery ajax request. The actual posting is working fine, but no matter what I try I cant seem to actually get a
Since you are using express,
res.contentType('json');
should be:
res.type('json');
but setting the type is not required since it is done automatically for you.
See the express api docs on res.type.
Also note that, for express, res.send({blah:"gee"});
automatically converts json objects using JSON.stringify internally. After clicking the above link, click on res.send
and, while you are at it, res.json
which saves a little processor overhead when you know you are sending JSON. Note that if you send JSON, the type is automatically set to JSON.
Always best to look at the source! Note that res.send calls this.json when it detects JSON, and that res.json calls this.send (yeah seems like a loop but it all works out).