当前位置:  开发笔记 > 前端 > 正文

Chrome通过jQuery通过ajax发送废话

如何解决《Chrome通过jQuery通过ajax发送废话》经验,为你挑选了0个好方法。

好吧,我使用的是Chrome版本28.0.1500.95 m和JQuery 1.9.1.

我正在做的是使用.get向微控制器发送一个短字节命令.但是在chrome中由于某种原因,随着我的命令发送了很多其他字节.

例如,这是firefox发送的内容:255 246 240

以下是铬从同一代码来源发送的内容:196 229 164 230 229 134 134 134 163 228 227 229 196 198 135 228 164 135 132 135 132 68 164 132 132 133 164 01 128 103 225 135 132 197 199 230 199 132 68 00 224 228 164 196 229 165 229 35 231 132 164 230 198 231 134 164 230 132 167 196 228 132 135 228 135 227 164 164 134 197 134 228 133 196 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

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



404 Not Found

404 Not Found

The requested URL /JS/jquery.min.map was not found on this server.

这是我实际命令的数据包:

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修复了这个问题.

推荐阅读
携手相约幸福
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有