JSON file on Server



Danny Cheah

Hi David,

I place my JSON file for my Report object on my cloud server and it didn't load the report at all. It kept showing Loading....

However if I follow the sample Report program and place it in my local directory and add it to my file manger it works perfectly. Does this means that JSON file can only be placed in the apps directory?


Thank you.
Best regards,
Danny Cheah

Danny Cheah
Hi David, I am looking at using HTTPClient sample. I believe it should work.
Thank you.
Best regards,
Danny Cheah

David Esperalta

Hello Danny,

If you run the app in a browser like Firefox, with the developers console opened, probably you can see what happen. Probably it's a CORS related issue: the server must provide the right CORS permissions that allows the app to reach the JSON file.

You can take a look at this website, since the possible configuration of the server depend on the server itself, it's not the same for all the posible servers.

If you can't configure the server to provide the right CORS permissions, it's probably possible to do it using some "bridge" for the JSON file, so, for example, we can prepare a PHP script, who read the JSON file and serve it to the app: then we can set the CORS permissions in the PHP script.

You can see various examples of setting the CORS permissions from PHP scripts, since are used in various app samples, mostly "Report*" samples. Anyway this is the code that can be used, more or less:



Danny Cheah

Hi David

I managed to resolve the problem already. Thank you for your pointers as to where to look. If you did not mentioned about CORS, I would not have know that CORS is the problem.


Thank you.
Best regards,
Danny Cheah

David Esperalta

Hello Danny,

Yes; remember to try the app in a browser like Firefox, with the developer console opened: unfortunately the AB debugger can't tell us about requests and the possible success or error on them, but the developer console of Firefox, for example, can do it, and, in fact,can tell us lot of other things, so we can use the internal debugger for take a quick look, but, if wanted more information, we need to run the app in a browser like Firefox, and we can do it just by press the right IDE button. So just temember to try the app in that way.



Danny Cheah
Yes David. I'm beginning to learn more and more each day and getting better now. Even though all this is new to me but the challenges makes it all worth the effort. Thanks a million. I hope that my application can go live this Sunday.
Thank you.
Best regards,
Danny Cheah

David Esperalta

Hello Danny,

Very good! But take your time if possible! Worries are good for nothing! :-)



Everybody can read the DecSoft's support forum for learning purposes, however only DecSoft's customers can post new threads. Purchase one or more licenses of some DecSoft's products in order to give this and other benefits.