XMLHttpRequest cannot send chariccter unicode as request header

I want to send XMLHttpRequest via JavaScript and everything works fine. But when I try to send Persian string instead of English I got this error:

TypeError: Cannot convert string to ByteString because the character at index 0 has value 1587 which is greater than 255.

      

Please note that this error only appears in Firefox and Chrome, but everything works fine in IE. This is a piece of code:

var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.setRequestHeader("serviceName", "سیبس"); // The line that cause of error

      

+3


source to share


1 answer


You can base64 encode and decode data on the server.



https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding

+1


source







All Articles