Change XHR posting to send JSON as the body, and set the right content type

Note that this means file uploads won't work anymore, and the server side has to be wise to receiving and parsing JSON.