0

I have a byte array in front-end generated by javascript that I want to send to java servlet through ajax. How can I do that?

Arijit Basu
  • 81
  • 1
  • 2

1 Answers1

0

See this q&a which discusses a jquery solution but also offers a vanilla js solution

var bytesToSend = [253, 0, 128, 1],
bytesArray = new Uint8Array(bytesToSend);
var xhr = new XMLHttpRequest();
xhr.open('POST', '%your_service_url%');
xhr.setRequestHeader('Content-Type', 'application/octet-stream');
xhr.send(bytesArray);
lance-java
  • 25,497
  • 4
  • 59
  • 101