As I am not able to find a way to set the content-type to JSON for the data I sent via XDomainRequest,
I naturally ask:
Is it IMPOSSIBLE to POST JSON with XDomainRequest?
"Only text/plain is supported for the request's Content-Type header"
As I am not able to find a way to set the content-type to JSON for the data I sent via XDomainRequest,
I naturally ask:
Is it IMPOSSIBLE to POST JSON with XDomainRequest?
"Only text/plain is supported for the request's Content-Type header"
看看其他一些问题,我会说这是可能的。
您仍然可以将 JSON 作为纯文本 POST 并让服务器端直接读取 POST 正文并进行处理,即使对于 IE 而言,缺少 Content-Type 也是如此。
您不能发送 content-type : application/json
xdr。您甚至不能发送任何其他自定义标头。xdr 仅限于text/plain
你能做的最好的就是JSON.stringify()
在服务器端使用和解析它。
xhr.send(JSON.stringify(jsonObject))