Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

302
Visualizações
QML using XMLHttpRequest edit JSON file not working

I import a JSON file in my program and I need to read & edit it.

(Only use QML not QT)

Reading part works totally fine , but writing part doesn't.

This is I try to use XMLHttpRequest sending my data to a json file(through qml workerScript)

"qrc:/1122test.json" is the json file's URL in my program

WorkerScript.onMessage = function(message) {
    var xhr = new XMLHttpRequest;
    xhr.open("POST" , "qrc:/1122test.json");
    xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
    xhr.onreadystatechange = function(){
        console.log("1122state" , xhr.readyState);
        if(xhr.readyState == 4){
//            console.log("1122state" , xhr.readyState);
        }
    }
    xhr.send(JSON.stringify({"email":"test@user.com" , "response":{"name" : "newName"}} ));
    console.log("saveed");

}

and my json file example

{
   "email":"hi@user.com" ,
   "response": {
       "name":"tester"
   }
   
}

Every time I open terminal cat the json file , it remain same("hi@user.com" didn't change to "test@user.com" and so was name part)

I already changed the json file's authority to 777

Every log in java showed but not show any error code.

This bother me for over a week , really appreciate any idea !!!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda