Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Synchronous JSON ?

See original GitHub issue


Bravo and Thanks for this amazing project - I really like the concept and I’m testing it to give our web application a new architecture.

To take an analogy with the classical Orders example:

  • I’d like to json-query table “Orders” from the server,
  • as “Products” and “ProductCategories” don’t change much, I’d like to load them once on initialisation, then JOIN on them with “Orders” (those quasi-static data may be updated later via a webworker polling for changes or a websocket).

So far the POC works well, I load data with something like:

var db = new alasql.Database("localdb");
alasql("USE DATABASE localdb");

dataAdrr = "http://server/query.php?object=Products";
dataQuery = 'SELECT * FROM JSON("' + dataAddr + '")';
alasql(dataQuery,[],function(data) {
        db.exec('CREATE TABLE Products'); =  data;

but now I face the problem of asynchronicity of JSON :

console.table (alasql("SELECT * from Products") 

returns nothing, as the data are not yet received…

The POC should show if we can load about 20 such tables, and perform locally the complex queries with multiple JOINS, subselects, groups… which we currently have on the php server.

If the POC succeeds, we’ll probably use Promises, Then, Resolve… to handle this asynchronicity, but is there is trick I can use right now to run JSON queries synchronously, something like “async: false” in previous jQuery versions ?

Thanks in advance !

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:17 (11 by maintainers)

github_iconTop GitHub Comments

agershuncommented, Feb 15, 2015
  1. Yes, you can not access file at your server because your server is not setup for CORS. I usually use GitHub rawgit feature to solve this problem in jsFiddle.
  2. It better to use Promises, like:
    function alasql2(sql, params) {
        return new Promise(function(resolve, reject){
            alasql(sql, params, function(data,err) {
                 if(err) {
                 } else {

Now you can use it with promises:

    alasql2('SELECT * FROM one', [])
        throw err;
mathiasrwcommented, Aug 24, 2015

Thank you for being persistent and keep getting inputs about the issue.

In the moment im running Chrome 41. I am not able to upgrade on this computer - but will try to run with 43 when I get back to my home computer

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to include JSON data in javascript synchronously without ...
I would like to do it at the beginning of page load in a synchronous way because data is needed during page load....
Read more >
sueddeutsche/json-sync: Enables real-time collaborative ...
json -sync. Enables real-time collaborative editing of arbitrary JSON objects. Table of contents. Installation; Demo; How does it work? Contact; Usage.
Read more >
sync-json - npm
Keep JSON files (or parts of them) in sync. Latest version: 1.0.2, last published: 6 years ago. Start using sync-json in your project...
Read more >
Synchronous and asynchronous requests - Web APIs | MDN
Synchronous requests block the execution of code which causes "freezing" on the screen and an unresponsive user experience. Asynchronous request.
Read more >
Is response.json() synchronous? : r/learnjavascript - Reddit
parse() is synchronous. The reason response.json() returns a promise is that the fetch() promise resolves as soon as the response headers have ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found