好的,我用的是铬版28.0.1500.95m和JQuery 1.9.1。
我正在做的是使用.get向微控制器发送一个短字节命令。但是,在chrome中,由于某种原因,大量的其他字节与我的命令一起被发送。
例如,这里是firefox发送的内容: 255 246 240
以下是铬从同一代码源代码中发送的内容: 196 229 164 230 230 134 134 228 227 229 196 196 198 135 228 228 132 132 135 164 132 132 164 01 128 103 225 132 197 199 230 132 68 00 228 164 196 229 165 229 235 231 231 231 230 134 134 163 228 227 227 164 134 134 134 196 133 133 133 167 102 255 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
铬响应头:
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服务器上,所以我不知道我能做些什么来检查数据包的错误。
我通过返回jQuery1.8解决了这个问题。
发布于 2013-08-28 22:57:54
您在chrome中获得的JS错误是由于它对JS源映射的支持。您可以尝试下载源映射,这样就不会得到404,或者禁用chrome中的源映射。
指向jQuery 1.9.1源地图的链接如下:http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.map
若要禁用,请参见Hide jquery.map errors in google chrome developer tools?
https://stackoverflow.com/questions/18217174
复制相似问题