无法使用 Closure 库将标头 Content-Type 更改为 application/json。这个 xhr.send () 是预检的。我已经在服务器端进行了所需的配置。但不知何故,我无法对 Content-Type 进行更改,它始终保持为空。有什么方法可以强制标题更改此代码?
xhr.headers.set('Content-Type','application/json');
Http-Method: OPTIONS
Content-Type:
Headers: {Accept=[*/*], Accept-Charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.3], accept-encoding=[gzip,deflate,sdch], Accept-Language=[en-US,en;q=0.8], Access-Control-Request-Headers=[origin, content-type], Access-Control-Request-Method=[POST], connection=[keep-alive], Content-Type=[null], Host=[localhost:8181], Origin=[http://localhost], Referer=[http://localhost/?], User-Agent=[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Ubuntu/12.04 Chromium/18.0.1025.168 Chrome/18.0.1025.168 Safari/535.19]}
Response-Code: 200
Content-Type: text/xml
Headers: {Allow=[POST, GET, OPTIONS, HEAD], Date=[Wed, 11 Jul 2012 16:31:04 GMT], Content-Length=[0]}