• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

226
Vistas
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 !!!

almost 3 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda