好的,我使用的是 chrome 版本 28.0.1500.95 m 和 JQuery 1.9.1。
我正在做的是使用 .get 向微控制器发送一个短字节命令。然而,由于某种原因,在 chrome 中,大量其他字节与我的命令一起发送。
例如,这是 Firefox 发送的内容:255 246 240
这是Chrome从同一代码来源发送的内容:196 229 164 230 229 134 134 134 134 134 163 228 227 227 229 196 198 135 228 135 135 135 132 132 135 132 132 68 132 68 132 132 132 132 133 133 133 133 133 164 01 128 103 103 225 135 132 199 199 230 199 230 199 230 199 230 199 132 199 230 199 132 199 230 199 132 199 230 132 199 230 132 199 132 68 00 224 228 164 196 229 165 229 35 231 132 164 230 198 231 134 164 230 132 132 167 196 228 132 135 228 135 228 135 227 164 164 164 164 164 134 134 134 228 134 228 133 196 133 133 133 133 133 133 133 133 133 133 133 167 102 255 255 246 246 246 246 246 240
**编辑我以错误的波特率阅读。它实际上是为句子“GET /JS/jquery.min.map HTTP/1.1”(“/www/JS/jquery.min.map”)提供字节值:文档打开:没有这样的文件或目录”加上它应该在最后发送的字节。
你会注意到我的命令在最后,所以这可能是某种奇怪的标题。
以下是进行此 ajax 调用的方法。
function SendUpdateCommand()
{
$.get(
"/cgi-bin/runcommand.sh?" + Math.floor(Math.random() * 1000) + ":cmd=254,124,1r10t300",
{},
function (responseText) {
var response = decodeURI(responseText || "no response text");
alert(response);
var returnValue = response.split("\n");
var bankStatus = returnValue[1].substring(0, returnValue[1].length-1);
var val = Number(bankStatus);
UpdateBankStatus(val);
},
"html"
);
}
这不是问题,但我的微控制器将这些读取为无效命令并返回大约十个零。任何帮助,将不胜感激。
谢谢
编辑
Firefox 请求标头:
GET /cgi-bin/runcommand.sh?401:cmd=254,124,1r10t300 HTTP/1.1
Host: 192.168.2.25
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0
Accept: text/html, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
X-Requested-With: XMLHttpRequest
Referer: http://192.168.2.25/test.html
Connection: keep-alive
Chrome 请求标头:
GET /cgi-bin/runcommand.sh?375:cmd=254,124,1r10t300 HTTP/1.1
Host: 192.168.2.25
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html, */*; q=0.01
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36
Referer: http://192.168.2.25/test.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Firefox 响应标头:
HTTP/1.1 200 OK
Date: Tue, 30 Nov 1999 00:05:11 GMT
Server: Boa/0.94.14rc21
Accept-Ranges: bytes
Connection: close
Content-Type: text/plain
Chrome 响应标头:
HTTP/1.1 200 OK
Date: Tue, 30 Nov 1999 00:00:10 GMT
Server: Boa/0.94.14rc21
Accept-Ranges: bytes
Connection: close
Content-type: text/plain
编辑
我认为这是导致问题的数据包:
GET /JS/jquery.min.map HTTP/1.1
Host: 192.168.2.25
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
HTTP/1.1 404 Not Found
Date: Tue, 30 Nov 1999 19:10:14 GMT
Server: Boa/0.94.14rc21
Accept-Ranges: bytes
Connection: close
Content-Type: text/html; charset=ISO-8859-1
<HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD>
<BODY><H1>404 Not Found</H1>
The requested URL /JS/jquery.min.map was not found on this server.
</BODY></HTML>
这是来自我的实际命令的数据包:
GET /cgi-bin/runcommand.sh?241:cmd=170,3,254,124,1,40r4t300 HTTP/1.1
Host: 192.168.2.25
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html, */*; q=0.01
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36
Referer: http://192.168.2.25/test.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
HTTP/1.1 200 OK
Date: Tue, 30 Nov 1999 19:10:15 GMT
Server: Boa/0.94.14rc21
Accept-Ranges: bytes
Connection: close
Content-type: text/plain
OK
170,11,0,0,
不知何故,这两个数据包相互干扰,可能在后端合并?我不确定。它在 boa 服务器上,所以我不确定我能做些什么来检查数据包的错误。
我通过回到 jquery 1.8 解决了这个问题。