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

后端 未结 11 2169
野趣味
野趣味 2020-11-21 22:35

I have a machine on my local lan (machineA) that has two web servers. The first is the in-built one in XBMC (on port 8080) and displays our library. The second server is a

11条回答
  •  有刺的猬
    2020-11-21 23:32

    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 
    

提交回复
热议问题