Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/449.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript XMLHttpRequest可以';t发送unicode字符作为请求头_Javascript_Html_Xmlhttprequest - Fatal编程技术网

Javascript XMLHttpRequest可以';t发送unicode字符作为请求头

Javascript XMLHttpRequest可以';t发送unicode字符作为请求头,javascript,html,xmlhttprequest,Javascript,Html,Xmlhttprequest,我想通过JavaScript发送XMLHttpRequest,一切正常。但当我尝试发送波斯语字符串而不是英语时,我遇到了以下错误: TypeError: Cannot convert string to ByteString because the character at index 0 has value 1587 which is greater than 255. 请注意,这个错误只出现在Firefox和Chrome上,但在IE上一切正常。 这是我的代码片段: var xmlhttp;

我想通过JavaScript发送XMLHttpRequest,一切正常。但当我尝试发送波斯语字符串而不是英语时,我遇到了以下错误:

TypeError: Cannot convert string to ByteString because the character at index 0 has value 1587 which is greater than 255.
请注意,这个错误只出现在Firefox和Chrome上,但在IE上一切正常。 这是我的代码片段:

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

您可以将数据编码成类似base64的格式,并在服务器上对其进行解码


谢谢你的回答,我用uri编码和解码解决了这个问题。我认为base64也可以。