How to get a cross-origin resource sharing (CORS) post request working

I finally stumbled upon this link “A CORS POST request works from plain javascript, but why not with jQuery?” that notes that jQuery 1.5.1 adds the

 Access-Control-Request-Headers: x-requested-with

header to all CORS requests. jQuery 1.5.2 does not do this. Also, according to the same question, setting a server response header of

Access-Control-Allow-Headers: *

does not allow the response to continue. You need to ensure the response header specifically includes the required headers. ie:

Access-Control-Allow-Headers: x-requested-with 

Leave a Comment