2013-08-13 16 views
8

OK, sto usando Chrome versione 28.0.1500.95 me JQuery 1.9.1.Chrome Invio di assurdità tramite ajax tramite JQuery

Quello che sto facendo è usare .get per inviare un comando byte corto a un microcontrollore. Tuttavia in chrome per qualche motivo un sacco di altri byte vengono inviati insieme al mio comando.

Per esempio ecco ciò invia firefox: 255 246 240

Ecco quello cromo sta inviando dalla stessa fonte codice: 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

** modifica Stavo leggendo che alla velocità di trasmissione errata. Fornisce realmente il valore byte per la frase "GET /JS/jquery.min.map HTTP/1.1" ("/www/JS/jquery.min.map"): documento aperto: nessun file o directory "più il byte che dovrebbe essere l'invio alla fine.

si noterà che il mio comando è alla fine, forse, questo è una sorta di colpo di testa strano.

di seguito è il metodo che rende questa chiamata 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" 
     ); 
    } 

questo non sarebbe un problema, ma il mio microcontrollore legge questi comandi non validi e restituisce una decina di zeri. Qualsiasi aiuto sarebbe apprezzato.

Grazie

EDIT

Firefox intestazioni di richiesta:

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 intestazioni di richiesta:

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 intestazione di risposta:

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 intestazione di risposta:

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 

Modifica

Credo che questo sia il pacchetto che causa il problema:

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> 

Questo è il pacchetto dal mio comando vero e proprio:

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, 

In qualche modo questi due pacchetti stanno entrando in un altro modo e forse vengono combinati nel back-end? Non ne sono sicuro. È su un server boa quindi non sono sicuro di cosa posso fare per il controllo degli errori dei pacchetti.

Ho risolto il problema tornando a jquery 1.8.

+1

tuoi parametri URL non sembrano corretti. Prova '" /cgi-bin/runcommand.sh?random= "+ Math.floor (Math.random() * 1000) +" & cmd = 254,124,1r10t300 "' – cfs

+0

No, fa parte dell'api del mio gateway. Estraiamo il numero casuale sul back-end – Poodimizer

+1

come stai determinando cosa "invia" firefox/chrome (il raggruppamento di numeri)? – Rob

risposta

Problemi correlati