Back

javascript - 不借助任何工具,使用浏览器的API 发送 ajax 请求

发布时间: 2023-09-18 08:54:00

refer to: POE

fetch('https://ixxxt/info.do',
    {
      method: 'POST',
      body: my_binary,
      headers
    }
  )
  .then(response => {
    if (!response.ok) {
      throw new Error('Network response was not ok');
    }
    return response.arrayBuffer();
  })
  .then(buffer => {
    // 在这里处理二进制数据
    console.log('Binary Data:', buffer);
  })
  .catch(error => {
    console.error('Error:', error);
  });

Back