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. Why XMLHttpRequest is 500
Forum Updated to NodeBB v4.3 + New Features

Why XMLHttpRequest is 500

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 2 Posters 1.3k Views 1 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.
  • T Offline
    T Offline
    THEFree
    wrote on last edited by
    #1

    #my web servise is php

    if php return a small text ,QML 's XMLHttpRequest is ok.

    but return a more text, zhe JSON 's lenght is 900+.

    zhe XMLHttp Request is 500

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @THEFree Error500 is an internal server error. AFAIK the length should not matter. Here is a small example that I tested its length is more than 900

      Item {
          width: 100
          height: 100
      
          function getData() {
              var xmlhttp = new XMLHttpRequest();
              var url = "https://jsonplaceholder.typicode.com/photos";
      
              xmlhttp.onreadystatechange=function() {
                  if (xmlhttp.readyState == XMLHttpRequest.DONE && xmlhttp.status == 200) {
                      console.log(xmlhttp.responseText.length);
                      console.log(xmlhttp.responseText);
                  }
              }
              xmlhttp.open("GET", url, true);
              xmlhttp.send();
          }
      
          Button {
              text: "Get Data"
              onClicked: getData()
          }
      }
      

      157

      T 1 Reply Last reply
      1
      • p3c0P p3c0

        @THEFree Error500 is an internal server error. AFAIK the length should not matter. Here is a small example that I tested its length is more than 900

        Item {
            width: 100
            height: 100
        
            function getData() {
                var xmlhttp = new XMLHttpRequest();
                var url = "https://jsonplaceholder.typicode.com/photos";
        
                xmlhttp.onreadystatechange=function() {
                    if (xmlhttp.readyState == XMLHttpRequest.DONE && xmlhttp.status == 200) {
                        console.log(xmlhttp.responseText.length);
                        console.log(xmlhttp.responseText);
                    }
                }
                xmlhttp.open("GET", url, true);
                xmlhttp.send();
            }
        
            Button {
                text: "Get Data"
                onClicked: getData()
            }
        }
        
        T Offline
        T Offline
        THEFree
        wrote on last edited by p3c0
        #3

        @p3c0 but im post

         var URL_Text_list = listurl;
                var UserName_Text_list = listusername;
                var PWD_Text_list = listpwd;
                console.log(URL_Text_list);
                console.log(UserName_Text_list);
                console.log(PWD_Text_list);
                var http = new XMLHttpRequest()
                var url = "http://192.16.1.33/index.php/index/Start/startReplyMessage";
                var params = "username="+PWD_Text_list+"&pwd="+UserName_Text_list + "&URL="+URL_Text_list;
                http.open("POST", url, true);
        
                //Send the proper header information along with the request
                http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                http.setRequestHeader("Content-length", params.length);
                http.setRequestHeader("Connection", "close");
        
                http.onreadystatechange = function(e) {//Call a function when the state changes.
                    console.log(http.status);
        
                    if(http.readyState == 4 && http.status == 200 ) {
        
                        var object_Json = JSON.parse(http.responseText);
        
                        for(var i in object_Json){
        
                            fruitModel.append(
                                        {
        
                                            "name":String(object_Json[i].record_name),
                                            "cost":String(object_Json[i].body)
                                        }
                                        )
                        }
        
                    }
                }
                http.send(params);
        
        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @THEFree

          • You might get more error information on the server side
          • Can you send the same info in the URL that is to say using GET instead of POST and see if the same error still persists ?

          157

          T 1 Reply Last reply
          1
          • p3c0P p3c0

            @THEFree

            • You might get more error information on the server side
            • Can you send the same info in the URL that is to say using GET instead of POST and see if the same error still persists ?
            T Offline
            T Offline
            THEFree
            wrote on last edited by
            #5

            @p3c0 use my chromium ,zhe php return is right

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              @THEFree Ok. can you try to debug and try to find out more information on the server side ?

              157

              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