Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. XmlHttpRequest error!
Forum Updated to NodeBB v4.3 + New Features

XmlHttpRequest error!

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.5k Views 3 Watching
  • 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
    DidaHarp
    wrote on last edited by DidaHarp
    #1

    Here is my qml code.I want to open the remote server to get the json data for my app,but it returns "no" with an error like such thing:
    QString::arg: Argument missing: 无法解析SSLv2_client_method中的符号“SSLv2_client_method”:ssl, (/lib/libssl.so.1.0.0: undefined symbol: SSLv2_client_method)

    The code:
    import QtQuick 2.2

    Rectangle{
    width: 300;height:300

    function getData(){
        var xhr = new XMLHttpRequest();
        var op = xhr.open("GET","https://api.douban.com/v2/music/search?q=Secrets&count=1",true,"09e72702d8897e9b1db57508899c7bd1","b13ac8bf373bc51b");
        xhr.send();
        if(op){
            console.log("yes");
        } else{
            console.log("no");
        }
    }
    MouseArea{
        anchors.fill: parent
        onClicked: parent.getData()
         }  
     }
    
    1 Reply Last reply
    0
    • D Offline
      D Offline
      DidaHarp
      wrote on last edited by
      #2

      Alright!I have abandoned XmlHttpRequest method.I'm going to use XmlListModel.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MartinH
        wrote on last edited by
        #3

        If you still want what was the problem, I think that it was ssl. You are requesting an https address so Qt call SSL but it appear that SSL is not fully or correctly installed.
        Try to use http instead or to fix ssl :)

        D 1 Reply Last reply
        0
        • M MartinH

          If you still want what was the problem, I think that it was ssl. You are requesting an https address so Qt call SSL but it appear that SSL is not fully or correctly installed.
          Try to use http instead or to fix ssl :)

          D Offline
          D Offline
          DidaHarp
          wrote on last edited by DidaHarp
          #4

          @MartinH Yeah! I still have to use XmlHttpRequest.And according to your reply, I changed the url to "http://mp3.baidu.com/dev/api/?tn=getinfo&ct=0&word=apologize&ie=utf-8&format=json".But it still returns "no",which means it doesn't work.What should I do now?

          The changed code is :
          function getData(){
          var xhr = new XMLHttpRequest();
          var op = xhr.open("GET","http://mp3.baidu.com/dev/api/?tn=getinfo&ct=0&word=apologize&ie=utf-8&format=json");
          xhr.send();
          if(op){
          console.log("yes");
          } else{
          console.log("no");
          }
          }

          p3c0P 1 Reply Last reply
          0
          • D DidaHarp

            @MartinH Yeah! I still have to use XmlHttpRequest.And according to your reply, I changed the url to "http://mp3.baidu.com/dev/api/?tn=getinfo&ct=0&word=apologize&ie=utf-8&format=json".But it still returns "no",which means it doesn't work.What should I do now?

            The changed code is :
            function getData(){
            var xhr = new XMLHttpRequest();
            var op = xhr.open("GET","http://mp3.baidu.com/dev/api/?tn=getinfo&ct=0&word=apologize&ie=utf-8&format=json");
            xhr.send();
            if(op){
            console.log("yes");
            } else{
            console.log("no");
            }
            }

            p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #5

            @DidaHarp XMLHttpRequest in QML only supports asynchronous only. So you may need to wait for the data to arrive. This can be done via state changes as usually done in JS

            function getData() {
                var xmlhttp = new XMLHttpRequest();
                var url = "http://mp3.baidu.com/dev/api/?tn=getinfo&ct=0&word=apologize&ie=utf-8&format=json";
            
                xmlhttp.onreadystatechange=function() {
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                        console.log(xmlhttp.responseText) // here is the output
                    }
                }
                xmlhttp.open("GET", url);
                xmlhttp.send();
            }
            

            157

            D 1 Reply Last reply
            0
            • p3c0P p3c0

              @DidaHarp XMLHttpRequest in QML only supports asynchronous only. So you may need to wait for the data to arrive. This can be done via state changes as usually done in JS

              function getData() {
                  var xmlhttp = new XMLHttpRequest();
                  var url = "http://mp3.baidu.com/dev/api/?tn=getinfo&ct=0&word=apologize&ie=utf-8&format=json";
              
                  xmlhttp.onreadystatechange=function() {
                      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                          console.log(xmlhttp.responseText) // here is the output
                      }
                  }
                  xmlhttp.open("GET", url);
                  xmlhttp.send();
              }
              
              D Offline
              D Offline
              DidaHarp
              wrote on last edited by
              #6

              @p3c0
              Wow!
              It worked!

              1 Reply Last reply
              0

              • Login

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