There is difference with request headers at least.
You can set them, and in my implementation I use arguments on 
onreadystatechanged function(myxhr)

See e.g. this https://github.com/kimmoli/maira/blob/master/qml/maira.qml#L622
and line 649 for content type example

-kimmo


From: devel-boun...@lists.sailfishos.org 
[mailto:devel-boun...@lists.sailfishos.org] On Behalf Of Kim Foder
Sent: 25. kesäkuuta 2016 21:41
To: Sailfish OS Developers
Subject: Re: [SailfishDevel] browser versus ajax


> Both captures have 200 response



Yes that much I can understand.



If you look at this picture (from wireshark), you will see that the first 
request is successful, but the second one behaves differently.



Even though it returns a status 200, something is wrong as shown in line 14 & 
15.



<removed>



I'm using the following code to do both requests:



function execCommand(command)

{

var xhr = new XMLHttpRequest();

xhr.onreadystatechange = function() {

console.log('ReadyState: ' + xhr.readyState);

if(xhr.readyState == 4)

{

console.log('Status: ' + xhr.status);

if (xhr.status == 200){

var fv = xhr.responseText;

console.log('Result: ' + fv);

}}

}

var c = "http://10.5.5.9:8080/"; + command;

console.log(c);

xhr.open('GET',c);

xhr.send();

}



And the following to execute the request (in a button onclick event):



execCommand("gp/gpControl/status");



The output for the failing request is:



execCommand: 89 - http//10.5.5.9:8080/gp/gpControl/status

:77 - ReadyState: 1



and after a very long time (at least it feels that way):



:77 - ReadyState: 4

:80 - Status: 0



/Kim



On fredag den 24. juni 2016 13.49.42 CEST Kimmo Lindholm wrote:

> And how it looks with your app?

> Both captures have 200 response

>

> Can show your code too?

>

> -kimmo

>

> -----Original Message-----

> From: 
> devel-boun...@lists.sailfishos.org<mailto:devel-boun...@lists.sailfishos.org>

> [mailto:devel-boun...@lists.sailfishos.org] On Behalf Of Kim Foder Sent:

> 23. kesäkuuta 2016 23:33

> To: devel@lists.sailfishos.org<mailto:devel@lists.sailfishos.org>

> Subject: [SailfishDevel] browser versus ajax

>

> Hi

>

> I'm trying to make a gopro Hero4 app for Sailfish, but have hit a wall :(

>

> When I send a request to the Hero (for example a status request http://

> 10.5.5.9:8080/gp/gpControl/status) in the address line of a browser (laptop

> or Jolla) I get the expected response, but when I try via ajax from qml I

> get no response (ready state 1 and after a long time ready state 4).

>

> I have captured the IP traffic (in pcap format), but do not have enough

> knowledge to interpret the results.

>

> If anyone here do have the knowledge to help me, I'll be gratefull.

>

> The captured sessions can be downloaded here:

> http://kimfoder.dk/capture.zip.

>

> /Kim

> _______________________________________________

> SailfishOS.org Devel mailing list

> To unsubscribe, please send a mail to 
> devel-unsubscr...@lists.sailfishos.org<mailto:devel-unsubscr...@lists.sailfishos.org>

> _______________________________________________

> SailfishOS.org Devel mailing list

> To unsubscribe, please send a mail to 
> devel-unsubscr...@lists.sailfishos.org<mailto:devel-unsubscr...@lists.sailfishos.org>




_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org

Reply via email to