使用: xhr.setRequestHeader();

xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Content-Length', JSON.stringify(data).length);
xhr.send(JSON.stringify(data));

 

注意: xhr.setRequestHeader() 必须在xhr.open()之后, xhr.send()之前调用;

 

相关文章:

  • 2021-11-02
  • 2022-12-23
  • 2021-10-12
  • 2021-12-24
  • 2021-11-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2021-08-01
相关资源
相似解决方案