Unsolved Why XMLHttpRequest is 500
-
#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
-
@THEFree Error
500
is an internal server error. AFAIK the length should not matter. Here is a small example that I tested its length is more than 900Item { 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() } }
-
@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);
-
- 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 ofPOST
and see if the same error still persists ?
-
@p3c0 use my chromium ,zhe php return is right
-
@THEFree Ok. can you try to debug and try to find out more information on the server side ?