Why XMLHttpRequest is 500
Unsolved
QML and Qt Quick
-
@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);