X-Requested-With is not allowed by Access-Control-Allow-Headers X-Requested-With is not allowed by Access-Control-Allow-Headers ajax ajax

X-Requested-With is not allowed by Access-Control-Allow-Headers


The error can be fixed by adding

header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');

in the server where ajax call leads to....


Remove this:

  headers: {    "Access-Control-Allow-Headers": "X-Requested-With",    "X-Requested-With": "XMLHttpRequest"          },

Access-Control-Allow-Headers is a response header, not a request header.

The server you are making the request to does not allow X-Requested-With.