the issue is nothing to do with JavaScript, but how the web server handles requests
This is what I was attempting to get at by adding the "text/html" content type in your ajax request. Unfortunately, I'm not too familiar with Nginx so, I can't provide much value in configuration there.
I am however, thoroughly convinced that your ajax request is either sending the wrong content type (text/txt) or none at all and Nginx is defaulting to text/txt.
For troubleshooting purposes I would not mess with the rewrite rules. They'll just complicate things. Remember that Ajax requests are redirects themselves. I would investigate the headers of your GET / POST ajax requests (in developer tools or firebug) and at the very least, rule out the content-type requested. Then, look around for resources on how Nginx handles or assigns default content types.
P.S I've had this very same issue with apache.