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

283
Visualizações
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 à 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