Page 1 of 1

How to load data from remote server to local database?

Posted: Sun Aug 25, 2013 5:56 pm
by Max Stolbinsky

Hi Everybody!
I need to implement following functionality: load some structured data form my own server into the app, save it to local DB (websql) and then show it on frontend. It will allow users to work with app even in offline mode.

I thought about 2 solutions:

  1. create rest service to load data from remote server, but i do not need to map it directly to interface. I need to map it to local database. How can I get access to results of service invoke function in js?

  2. Use just normal JS function and make call using XMLHttpRequest. But this solution raises security error because JS attempts to connect to another domain.

    Advice me please what is best practice to do this?

    Thanks!


How to load data from remote server to local database?

Posted: Sun Aug 25, 2013 6:32 pm
by maxkatz

For #1, you can access to returned data in service's 'complete' event. Check the docs on services. There are standard jQuery callbacks.


How to load data from remote server to local database?

Posted: Sun Aug 25, 2013 6:38 pm
by Max Stolbinsky

Yep, thanks. I prefer way #1 - it looks more clear. Found this callback. It solves my problems.