A
A
Alexander2014-11-08 05:56:29
Android
Alexander, 2014-11-08 05:56:29

QML Android. XMLHttpRequest only works with wifi enabled, why?

I use this structure to get data from the site:

var request = new XMLHttpRequest()
    request.open("GET", url)
    request.onreadystatechange = function () {

        console.log("ready") // - это первое сообщение

        if (request.readyState === XMLHttpRequest.DONE) {
            if (request.status === 200) {
                var jsonObject = JSON.parse(request.responseText)
                loaded(jsonObject)
            } else {
                console.log("HTTP request failed", request.status)
                errMessage.text = "Ошибка соединения с сервером :-("
            }
        }
    }
    request.send()

the size of the received data is not large, about ~ 200 characters (when downloading them through the same browser, this happens in a fraction of a second). When WiFi is on, everything works, but if you turn it off, everything is covered with a copper basin. Even the very first "ready" message is not displayed in the log. Maybe you need to add something to the manifest so that the application has privileges to use 3g? Or is it still a strange-incomprehensible cant in my code? =/
ps checked on two smartphones with cianogen and miui firmware
p.p.s. android.permission.INTERNET is present

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2014-11-09
@wxmaper

Figured out what the problem was! =[ I used Qt 5.4.0 beta to build the project. I downloaded version 5.3.2 - everything works there in both 3g and wifi! 2 days sat stupid ((spent so much time ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question