Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

281
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!