Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

282
Vistas
Ext JS 7.0: Get responded JSON string from router

I wrote an Ext JS 7.0 app with a grid that uses Ext Direct to connect to a SQL database based on the example by Sencha (https://docs.sencha.com/extjs/7.0.0/guides/backend_connectors/direct/mysql_php.html). This works fine.

The app has also some views with a few textfields. Their content is stored in the database, too, but in a different table, so I added the necessary functions to QueryDatabase.php and extended config.php. Now writing into the database works by simply calling the corresponding (php) function in the controller, e. g. QueryDatabase.updateSettings(JSONstring);.

I also want to initially populate the textfields with the data stored in the database and this is where I get into trouble.

If I call the proper read function and assign it to a variable, e. g. settingsJSON = QueryDatabase.getSettings();, settingsJSON stays undefined, although I can see in the browser that router.php returns the correct result (like "{\"Setting1\":\"a value\",\"Setting2\":\"another value\"}").

Since the request is asynchronous, I tried to use a callback function (according to https://docs.sencha.com/extjs/7.0.0/classic/Ext.direct.RemotingProvider.html#cfg-actions):

onSettingsRefreshClick: function() {
    console.log('Hello world!');
    QueryDatabase.getSettings(function(result, e, success, options) {
    console.log('Hello again!');
        var t, action, method;

        t = e.getTransaction();
        action = t.action;
        method = t.method;

        if (e.status) {
            console.log(Ext.encode(result));
        }
    })
}

But this isn't working either. router.php still delivers the correct result, but it isn't shown in the console. Obviously the whole callback function isn't executed as 'Hello again!' also doesnt't appear in the console ('Hello world!' does). So how do I assign the JSON string returned by router.php to a variable?

about 4 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda