Max Stolbinsky
Posts: 0
Joined: Fri Aug 23, 2013 9:09 pm

How to load data from remote server to local database?

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!

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How to load data from remote server to local database?

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

Max Stolbinsky
Posts: 0
Joined: Fri Aug 23, 2013 9:09 pm

How to load data from remote server to local database?

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

Return to “Issues”