Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. XMLHttpRequest -> timeout and ontimeout doesnt work
QtWS25 Last Chance

XMLHttpRequest -> timeout and ontimeout doesnt work

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DerMas
    wrote on 19 Mar 2014, 13:23 last edited by
    #1

    I use the XMLHttpRequest in my QtQuick app in order to access a rest service. I'd like to react to the situation, if the rest service is gone. So I tried to use timeout and ontimeout to abort the request and do other stuff. But it doesnt work. Am I doing something wrong or is it just not compatible with QtQuick?

    @
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function () {
    if (xhr.state === 200){
    console.log("Response: " + xhr.responseText);
    }
    };

    xhr.open("GET", "http://myurl", true);
    xhr.timeout = 1000;
    xhr.ontimeout = function () { console.log("Timed out"); }
    xhr.send();
    

    @

    1 Reply Last reply
    0
    • O Offline
      O Offline
      onek24
      wrote on 19 Mar 2014, 13:40 last edited by
      #2

      Hello,

      i have not worked with XMLHttpRequest, so i can not help you, but this might:

      • "XMLHttpRequest Example":http://qt-project.org/doc/qt-4.8/declarative-xml-xmlhttprequest-xmlhttprequest-example-qml.html
      • "XMLHttpRequest":http://qt-project.org/doc/qt-5.0/qtqml/qtqml-javascript-qmlglobalobject.html#xmlhttprequest
      • "XMLHttpRequest from QML in Cascades":https://supportforums.blackberry.com/t5/Native-Development/You-CAN-use-XMLHttpRequest-from-QML-in-Cascades/td-p/2021907
      • "Using XMLHttpRequest for HTTPS Post to server with SSL certificate":http://www.qtcentre.org/threads/44629-Using-XMLHttpRequest-for-HTTPS-Post-to-server-with-SSL-certificate
      • "Google: QML XMLHttpRequest":https://www.google.de/search?q=qml+xmlhttprequest
      1 Reply Last reply
      0
      • D Offline
        D Offline
        DerMas
        wrote on 19 Mar 2014, 13:57 last edited by
        #3

        Unfortunately your list doesnt help.

        If others have the same problem, my current workaround is to use a Timer after every request and check if a variable has been touched until the Timer is triggered.

        1 Reply Last reply
        0

        1/3

        19 Mar 2014, 13:23

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved